diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index ea2ffedd4cb..5cb8cf6bed8 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -124,7 +124,6 @@ bool QHostInfoResult::event(QEvent *event) // we didn't have a context object, or it's still alive if (!withContextObject || receiver) slotObj->call(const_cast(receiver.data()), args); - slotObj->destroyIfLastRef(); deleteLater(); return true; diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 2176b464aed..28654f4e141 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -51,6 +51,12 @@ public: moveToThread(receiver->thread()); } + ~QHostInfoResult() + { + if (slotObj) + slotObj->destroyIfLastRef(); + } + void postResultsReady(const QHostInfo &info); Q_SIGNALS: @@ -64,6 +70,8 @@ private: : receiver(other->receiver), slotObj(other->slotObj), withContextObject(other->withContextObject) { + if (slotObj) + slotObj->ref(); // cleanup if the application terminates before results are delivered connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QObject::deleteLater);