Piccole modifiche al codice
[qmemory] / testThread.cpp
index e3087e1..b41a56e 100644 (file)
@@ -3,52 +3,51 @@
 #include <qdebug.h>
 #include <QMessageBox>
 #include <QDateTime>
-TestThread::TestThread(QObject *parent):QThread(parent){
-    colore=0;
 
+TestThread::TestThread(QObject *parent):QThread(parent)
+{
+    colore=0;
     index=0;
     _score=0;
-
     qsrand(QDateTime::currentDateTime().toTime_t());
 
 }
-TestThread::~TestThread(){
+
+TestThread::~TestThread()
+{
 
 }
 void TestThread::run(){
     sleep(1);
-    while(true){
-    mutex.lock();
-    qsrand(QDateTime::currentDateTime().toTime_t());
-    sequenza.append(qrand()%9);
-    int i=0;
-    index=0;
+    forever{
+        mutex.lock();
 
-    emit disableInterface();
-    while(i<sequenza.size())
-    {
-      emit generate(sequenza.at(i));
-      qDebug()<<sequenza.at(i);
-      msleep(500 - (_score*2));
-      emit generate(sequenza.at(i));
-      msleep(500 - (_score*2));
-      i++;
-    }
-    i=0;
-    emit enableInterface();
-    attendiInputUtente.wait(&mutex);
+        qsrand(QDateTime::currentDateTime().toTime_t());
+        sequenza.append(qrand()%9);
+        int i=0;
+        index=0;
+
+        emit disableInterface();
+        while(i<sequenza.size())
+        {
+          emit generate(sequenza.at(i));
+          msleep(500 - (_score*2));
+          emit generate(sequenza.at(i));
+          msleep(500 - (_score*2));
+          i++;
+        }
+        i=0;
+        emit enableInterface();
+        attendiInputUtente.wait(&mutex);
 
-    mutex.unlock();
+        mutex.unlock();
 
     }
 
 
 }
 
-void TestThread::updateCaption(int inputUser){
-
-
-
+void TestThread::addUserInput(int inputUser){
         if(sequenza.at(index)==inputUser)
         {
             index++;