diff options
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 10 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyhttpimpl.cpp | 6 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index f83dc4fb48..d5b4eec0ed 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -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; } } diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index e1ec9a9a95..3e92126fde 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -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 { |