QHostInfo: fix leaking slot object
We were not ref'ing or deref'ing the slot object in the various places that owned it. So, if, in the end, the QHostInfoResult object didn't call the slot we would leak the slot object. Pick-to: 6.6 6.5 6.2 5.15 Fixes: QTBUG-115263 Change-Id: I45f43756c7589470045d97b59257ccfd85a325b7 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
1e3bf10786
commit
061ab84e98
@ -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<QObject*>(receiver.data()), args);
|
||||
slotObj->destroyIfLastRef();
|
||||
|
||||
deleteLater();
|
||||
return true;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user