From 693c9e6b1b2f160862a7490af78072a244fa5b9f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 21 Jul 2023 11:12:50 +0200 Subject: [PATCH] QHostInfo: fix remaining slotObj leaks We failed to delete the slot object when lookUpHost() was called in these (exceptional) circumstances: - on a thread with no event dispatcher - after application shut-down, when the QHostInfoLookupManager Q_APPLICATION_STATIC was destroyed already Fix by adding the missing destroyIfLastRef() calls into these code paths, too. Amends ad5eb297e179a164e297a7c2eb3b9674a1196605. This would be so much easier if we had SlotObjUniquePtr... Pick-to: 6.6 6.5 6.2 5.15 Task-number: QTBUG-115263 Change-Id: Ief8bf125bc196742c0ce59c1fd87ab93242fc0da Reviewed-by: Ivan Solovev Reviewed-by: Qt CI Bot --- src/network/kernel/qhostinfo.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 5cb8cf6bed..e6cba483f9 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -742,6 +742,8 @@ int QHostInfo::lookupHostImpl(const QString &name, if (!QAbstractEventDispatcher::instance(QThread::currentThread())) { qWarning("QHostInfo::lookupHost() called with no event dispatcher"); + if (slotObj) + slotObj->destroyIfLastRef(); return -1; } @@ -802,6 +804,8 @@ int QHostInfo::lookupHostImpl(const QString &name, QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection); manager->scheduleLookup(runnable); + } else if (slotObj) { + slotObj->destroyIfLastRef(); } #endif // Q_OS_WASM return id;