Problemi con emit score
[qmemory] / testThread.cpp
index c6c6719..5dd1a2f 100644 (file)
@@ -18,15 +18,13 @@ TestThread::~TestThread()
 
 }
 void TestThread::run(){
-    sleep(2);
+    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);
-                attendiInputUtente.wakeAll();
 
+           if(index==sequenza.size()){
+                msleep(300);
+                attendiInputUtente.wakeAll();
             }
         }
         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();
-
 }