From 3f7d1dd5f323970f1047ab058159ec48d94012f7 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 28 Mar 2011 17:53:45 +0100 Subject: 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 --- src/network/bearer/qsharednetworksession.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 QSharedNetworkSessionManager::getSession(QNetworkConfiguration config) { QSharedNetworkSessionManager *m(sharedNetworkSessionManager()); @@ -69,7 +74,7 @@ QSharedPointer QSharedNetworkSessionManager::getSession(QNetwor return p; } //otherwise make one - QSharedPointer session(new QNetworkSession(config)); + QSharedPointer session(new QNetworkSession(config), doDeleteLater); m->sessions[config] = session; return session; } -- cgit v0.12