X-Git-Url: http://git.maemo.org/git/?p=qmemory;a=blobdiff_plain;f=testThread.cpp;h=e3087e1ef0163ff8adc9b5fe3623552905c4a70a;hp=fcdf34a5bf0682c451550595149300c11ddf26c8;hb=44f2521902036db1caced5a4f418e78ef3a686ab;hpb=2c930692d1472c797cae05f6f942c3a39faabef8;ds=inline diff --git a/testThread.cpp b/testThread.cpp index fcdf34a..e3087e1 100644 --- a/testThread.cpp +++ b/testThread.cpp @@ -5,7 +5,7 @@ #include TestThread::TestThread(QObject *parent):QThread(parent){ colore=0; - attendiInputUtente=false; + index=0; _score=0; @@ -18,7 +18,7 @@ TestThread::~TestThread(){ void TestThread::run(){ sleep(1); while(true){ - + mutex.lock(); qsrand(QDateTime::currentDateTime().toTime_t()); sequenza.append(qrand()%9); int i=0; @@ -35,12 +35,11 @@ void TestThread::run(){ i++; } i=0; - attendiInputUtente=true; emit enableInterface(); + attendiInputUtente.wait(&mutex); + + mutex.unlock(); - while(attendiInputUtente){ - msleep(1); - } } @@ -48,7 +47,7 @@ void TestThread::run(){ void TestThread::updateCaption(int inputUser){ - if(attendiInputUtente){ + if(sequenza.at(index)==inputUser) { @@ -57,7 +56,7 @@ void TestThread::updateCaption(int inputUser){ emit score(_score); if(index==sequenza.size()){ sleep(1); - attendiInputUtente=false; + attendiInputUtente.wakeAll(); index=0; } } @@ -66,14 +65,14 @@ void TestThread::updateCaption(int inputUser){ _score=0; sequenza.clear(); index=0; - attendiInputUtente=true; + attendiInputUtente.wakeAll(); } - } + } void TestThread::genera() { - attendiInputUtente=false; + attendiInputUtente.wakeAll(); }