threading issues fixed
This commit is contained in:
parent
a8501be581
commit
7591d805c9
13 changed files with 251 additions and 93 deletions
|
@ -42,6 +42,9 @@ void DatabaseThread::run()
|
|||
QEventLoop threadLoop;
|
||||
QStringList crewList;
|
||||
|
||||
// Register thread loop end signal
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), &threadLoop, SLOT(quit()));
|
||||
|
||||
// Quick time scan
|
||||
if (crewList.length() <= 3)
|
||||
{
|
||||
|
@ -58,6 +61,7 @@ void DatabaseThread::run()
|
|||
|
||||
QEventLoop *waitingLoop = new QEventLoop();
|
||||
QTimer::singleShot(10000, waitingLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
|
||||
waitingLoop->exec();
|
||||
delete waitingLoop;
|
||||
|
||||
|
@ -70,8 +74,11 @@ void DatabaseThread::run()
|
|||
scanCrewMembersList(crewList, crewMaxPages, 10000);
|
||||
emit playerNameUpdated();
|
||||
|
||||
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
|
||||
threadLoop.exec();
|
||||
if (threadRunning)
|
||||
{
|
||||
QTimer::singleShot(300000, &threadLoop, SLOT(quit()));
|
||||
threadLoop.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +86,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
|
|||
{
|
||||
foreach (const QString &crewID, crewList)
|
||||
{
|
||||
if (crewID != "0")
|
||||
if (threadRunning && crewID != "0")
|
||||
{
|
||||
QNetworkAccessManager *netManager = new QNetworkAccessManager();
|
||||
|
||||
|
@ -93,6 +100,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
|
|||
|
||||
QEventLoop *downloadLoop = new QEventLoop();
|
||||
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
|
||||
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
|
||||
downloadLoop->exec();
|
||||
delete downloadLoop;
|
||||
|
@ -138,6 +146,7 @@ void DatabaseThread::scanCrewReference(QStringList crewList, int requestDelay)
|
|||
|
||||
QEventLoop *waitingLoop = new QEventLoop();
|
||||
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
|
||||
waitingLoop->exec();
|
||||
delete waitingLoop;
|
||||
|
||||
|
@ -153,7 +162,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
|
|||
{
|
||||
foreach (const QString &crewID, crewList)
|
||||
{
|
||||
if (crewID != "0")
|
||||
if (threadRunning && crewID != "0")
|
||||
{
|
||||
int currentPage = 0;
|
||||
int foundPlayers = 0;
|
||||
|
@ -173,6 +182,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
|
|||
|
||||
QEventLoop *downloadLoop = new QEventLoop();
|
||||
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), downloadLoop, SLOT(quit()));
|
||||
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
|
||||
downloadLoop->exec();
|
||||
delete downloadLoop;
|
||||
|
@ -207,6 +217,7 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
|
|||
|
||||
QEventLoop *waitingLoop = new QEventLoop();
|
||||
QTimer::singleShot(requestDelay, waitingLoop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(threadEndCommited()), waitingLoop, SLOT(quit()));
|
||||
waitingLoop->exec();
|
||||
delete waitingLoop;
|
||||
|
||||
|
@ -221,3 +232,9 @@ void DatabaseThread::scanCrewMembersList(QStringList crewList, int maxPages, int
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseThread::doEndThread()
|
||||
{
|
||||
threadRunning = false;
|
||||
emit threadEndCommited();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue