QNetworkAccessManager: delete the httpThread

The httpThread was using deleteLater the finished signal of the
thread to call the deleteLater slot. If the QNetworkAccessManager is
deleted when the application is closed then then fished is emitted
but we never return to the eventloop so the deletion is never done.

This will delete the httpThread directly instead of using deleteLater

Task-number: QTBUG-25487
Change-Id: I1fdbd4eca01e8bd8b3a98936298e5c78217752b4
Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
bb10
Martin Petersson 2012-06-13 08:59:35 +02:00 committed by Qt by Nokia
parent cf7c93b928
commit 534bcc9667
2 changed files with 12 additions and 4 deletions

View File

@ -1280,9 +1280,12 @@ void QNetworkAccessManagerPrivate::clearCache(QNetworkAccessManager *manager)
manager->d_func()->authenticationManager->clearCache();
if (manager->d_func()->httpThread) {
// The thread will deleteLater() itself from its finished() signal
manager->d_func()->httpThread->quit();
manager->d_func()->httpThread->wait(5000);
if (manager->d_func()->httpThread->isFinished())
delete manager->d_func()->httpThread;
else
QObject::connect(manager->d_func()->httpThread, SIGNAL(finished()), manager->d_func()->httpThread, SLOT(deleteLater()));
manager->d_func()->httpThread = 0;
}
}
@ -1290,9 +1293,12 @@ void QNetworkAccessManagerPrivate::clearCache(QNetworkAccessManager *manager)
QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate()
{
if (httpThread) {
// The thread will deleteLater() itself from its finished() signal
httpThread->quit();
httpThread->wait(5000);
if (httpThread->isFinished())
delete httpThread;
else
QObject::connect(httpThread, SIGNAL(finished()), httpThread, SLOT(deleteLater()));
httpThread = 0;
}
}

View File

@ -620,7 +620,6 @@ void QNetworkReplyHttpImplPrivate::postRequest()
// At some point we could switch to having multiple threads if it makes sense.
managerPrivate->httpThread = new QThread();
managerPrivate->httpThread->setObjectName(QStringLiteral("httpThread"));
QObject::connect(managerPrivate->httpThread, SIGNAL(finished()), managerPrivate->httpThread, SLOT(deleteLater()));
managerPrivate->httpThread->start();
thread = managerPrivate->httpThread;
@ -917,9 +916,12 @@ void QNetworkReplyHttpImplPrivate::postRequest()
replyDownloadData(delegate->synchronousDownloadData);
}
// End the thread. It will delete itself from the finished() signal
thread->quit();
thread->wait(5000);
if (thread->isFinished())
delete thread;
else
QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
finished();
} else {