QHostInfo: use SlotObjUniquePtr
Drops the direct deref'ing. Pick-to: 6.6 6.5 Change-Id: I9f159244d50572659fa8e9cabfbef47e769ac54e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>bb10
parent
d7dc4d3ebb
commit
5bb4020cbe
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<const QObject> receiver = nullptr;
|
||||
QtPrivate::QSlotObjectBase *slotObj = nullptr;
|
||||
QtPrivate::SlotObjUniquePtr slotObj;
|
||||
const bool withContextObject = false;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue