diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index e6cba483f9d..d15c4f27ca1 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -107,7 +107,7 @@ void QHostInfoResult::postResultsReady(const QHostInfo &info) auto result = new QHostInfoResult(this); Q_CHECK_PTR(result); - auto metaCallEvent = QMetaCallEvent::create(slotObj, nullptr, signal_index, info); + auto metaCallEvent = QMetaCallEvent::create(slotObj.get(), nullptr, signal_index, info); Q_CHECK_PTR(metaCallEvent); qApp->postEvent(result, metaCallEvent); } diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 28654f4e141..d883a33cdd2 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -51,12 +51,6 @@ public: moveToThread(receiver->thread()); } - ~QHostInfoResult() - { - if (slotObj) - slotObj->destroyIfLastRef(); - } - void postResultsReady(const QHostInfo &info); Q_SIGNALS: @@ -67,11 +61,11 @@ protected: private: QHostInfoResult(const QHostInfoResult *other) - : receiver(other->receiver), slotObj(other->slotObj), + : receiver(other->receiver), slotObj(other->slotObj.get()), // ugly, but copy the pointer... withContextObject(other->withContextObject) { if (slotObj) - slotObj->ref(); + slotObj->ref(); // ... and ref it here // cleanup if the application terminates before results are delivered connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &QObject::deleteLater); @@ -80,7 +74,7 @@ private: } QPointer receiver = nullptr; - QtPrivate::QSlotObjectBase *slotObj = nullptr; + QtPrivate::SlotObjUniquePtr slotObj; const bool withContextObject = false; };