diff --git a/DatabaseThread.cpp b/DatabaseThread.cpp index 84de545..08e4ffa 100755 --- a/DatabaseThread.cpp +++ b/DatabaseThread.cpp @@ -33,6 +33,7 @@ DatabaseThread::DatabaseThread(CrewDatabase *crewDB, QObject *parent) : QThread(parent), crewDB(crewDB) { crewMaxPages = 83; + threadRunning = true; } void DatabaseThread::run() @@ -52,20 +53,22 @@ void DatabaseThread::run() emit playerNameUpdated(); } - QEventLoop waitingLoop; - QTimer::singleShot(10000, &waitingLoop, SLOT(quit())); - waitingLoop.exec(); + QEventLoop *waitingLoop = new QEventLoop(); + QTimer::singleShot(10000, waitingLoop, SLOT(quit())); + waitingLoop->exec(); + delete waitingLoop; -dbtBegin: - crewList = crewDB->getCrews(); + while (threadRunning) + { + crewList = crewDB->getCrews(); - // Long time scan - scanCrewMembersList(crewList, crewMaxPages, 10000); - emit playerNameUpdated(); + // Long time scan + scanCrewMembersList(crewList, crewMaxPages, 10000); + emit playerNameUpdated(); - QTimer::singleShot(300000, &threadLoop, SLOT(quit())); - threadLoop.exec(); - goto dbtBegin; + QTimer::singleShot(300000, &threadLoop, SLOT(quit())); + threadLoop.exec(); + } } void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay) diff --git a/DatabaseThread.h b/DatabaseThread.h index 631c4be..a272bf1 100755 --- a/DatabaseThread.h +++ b/DatabaseThread.h @@ -32,6 +32,7 @@ public: private: CrewDatabase *crewDB; void scanCrewMembersList(QStringList crewList, int maxPages, int requestDelay); + bool threadRunning; int crewMaxPages; int plyrPerReq;