summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2020-11-06 12:51:42 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2020-11-06 21:03:52 +0000
commit1c6d6cbb62c5e93cbcad2d740c3b0ed01095618c (patch)
treebba109ab89d53cd5b7560bc369ad745da599205b /src/network
parent7b2011bd1444f9ed4efeacd9b41aa5a01039cff3 (diff)
QNAM: Work around QObject finicky orphan cleanup details
Details described in a comment. Task-number: QTBUG-88063 Pick-to: 5.15 Change-Id: I763ecfedf518de97615e04a8eaae0fe1fd784f52 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 921b482d10..555b609433 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -791,7 +791,17 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
// For the synchronous HTTP, this is the normal way the delegate gets deleted
// For the asynchronous HTTP this is a safety measure, the delegate deletes itself when HTTP is finished
- QObject::connect(thread, SIGNAL(finished()), delegate, SLOT(deleteLater()));
+ QMetaObject::Connection threadFinishedConnection =
+ QObject::connect(thread, SIGNAL(finished()), delegate, SLOT(deleteLater()));
+
+ // QTBUG-88063: When 'delegate' is deleted the connection will be added to 'thread''s orphaned
+ // connections list. This orphaned list will be cleaned up next time 'thread' emits a signal,
+ // unfortunately that's the finished signal. It leads to a soft-leak so we do this to disconnect
+ // it on deletion so that it cleans up the orphan immediately.
+ QObject::connect(delegate, &QObject::destroyed, delegate, [threadFinishedConnection]() {
+ if (bool(threadFinishedConnection))
+ QObject::disconnect(threadFinishedConnection);
+ });
// Set the properties it needs
delegate->httpRequest = httpRequest;