summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Petersson <Martin.Petersson@nokia.com>2012-06-13 08:59:35 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-20 15:45:07 +0200
commit534bcc96676ac02fc327f9e43d3785c7424b0750 (patch)
tree4d2796c8c90db9258b450cfca36cabe670c17318 /src
parentcf7c93b9283d6dded4fd0e57ed771d8470206093 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp10
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp6
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 {