diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-03-28 16:53:45 (GMT) |
---|---|---|
committer | Adrian Constantin <adrian.constantin@nokia.com> | 2011-04-07 09:27:47 (GMT) |
commit | 3f7d1dd5f323970f1047ab058159ec48d94012f7 (patch) | |
tree | fee8e5d4e9afe052102bd53ef40acace181f859c | |
parent | a30decc01878ab2435a9a48f4963c07b5e08c5b6 (diff) | |
download | Qt-3f7d1dd5f323970f1047ab058159ec48d94012f7.zip Qt-3f7d1dd5f323970f1047ab058159ec48d94012f7.tar.gz Qt-3f7d1dd5f323970f1047ab058159ec48d94012f7.tar.bz2 |
Ensure shared network session deleted from correct thread
Due to threaded http, the shared QNetworkSession can have its last
reference removed from a http delegate thread. To avoid this deadlocking
use a deleteLater custom deleter so that the QNS is deleted from the
thread it has affinity for.
Reviewed-by: Markus Goetz
Task-Number: QTBUG-17464
-rw-r--r-- | src/network/bearer/qsharednetworksession.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/network/bearer/qsharednetworksession.cpp b/src/network/bearer/qsharednetworksession.cpp index 28ca173..fcb0128 100644 --- a/src/network/bearer/qsharednetworksession.cpp +++ b/src/network/bearer/qsharednetworksession.cpp @@ -59,6 +59,11 @@ inline QSharedNetworkSessionManager* sharedNetworkSessionManager() return rv; } +static void doDeleteLater(QObject* obj) +{ + obj->deleteLater(); +} + QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(QNetworkConfiguration config) { QSharedNetworkSessionManager *m(sharedNetworkSessionManager()); @@ -69,7 +74,7 @@ QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(QNetwor return p; } //otherwise make one - QSharedPointer<QNetworkSession> session(new QNetworkSession(config)); + QSharedPointer<QNetworkSession> session(new QNetworkSession(config), doDeleteLater); m->sessions[config] = session; return session; } |