Problemi con emit score
[qmemory] / testThread.cpp
index b41a56e..5dd1a2f 100644 (file)
@@ -21,12 +21,10 @@ void TestThread::run(){
     sleep(1);
     forever{
         mutex.lock();
-
         qsrand(QDateTime::currentDateTime().toTime_t());
         sequenza.append(qrand()%9);
         int i=0;
         index=0;
-
         emit disableInterface();
         while(i<sequenza.size())
         {
@@ -36,15 +34,12 @@ void TestThread::run(){
           msleep(500 - (_score*2));
           i++;
         }
+
         i=0;
         emit enableInterface();
         attendiInputUtente.wait(&mutex);
-
         mutex.unlock();
-
     }
-
-
 }
 
 void TestThread::addUserInput(int inputUser){
@@ -53,25 +48,23 @@ void TestThread::addUserInput(int inputUser){
             index++;
             _score++;
             emit score(_score);
-            if(index==sequenza.size()){
-                sleep(1);
+
+           if(index==sequenza.size()){
+                msleep(300);
                 attendiInputUtente.wakeAll();
-                index=0;
             }
         }
         else{
             emit exit(_score);
-            _score=0;
-            sequenza.clear();
-            index=0;
-            attendiInputUtente.wakeAll();
         }
 
 }
 
 void TestThread::genera()
 {
-
+    sequenza.clear();
+    index=0;
+    _score=0;
+    emit score(_score);
     attendiInputUtente.wakeAll();
-
 }