Plug a memory leak introduced in e24a4976be

While it is correct not to call the functor when the context object has
been destroyed, we still need ot clean up the slotObj. It's a low-
probability memory leak: the context object has to disappear while
waiting for a host resolution, and for repeated requests for the same
host the cache takes over anyway.

Task-number: QTBUG-76276
Change-Id: Id9daf391353b8252443f3186a7d504d70c553b24
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Volker Hilsheimer 2019-07-30 16:42:44 +02:00
parent 652085c5c2
commit 23e605cc5b
1 changed files with 6 additions and 6 deletions

View File

@ -105,12 +105,12 @@ public Q_SLOTS:
inline void emitResultsReady(const QHostInfo &info)
{
if (slotObj) {
// we used to have a context object, but it's already destroyed
if (withContextObject && !receiver)
return;
QHostInfo copy = info;
void *args[2] = { 0, reinterpret_cast<void *>(&copy) };
slotObj->call(const_cast<QObject*>(receiver.data()), args);
// we either didn't have a context object, or it's still alive
if (!withContextObject || receiver) {
QHostInfo copy = info;
void *args[2] = { 0, reinterpret_cast<void *>(&copy) };
slotObj->call(const_cast<QObject*>(receiver.data()), args);
}
slotObj->destroyIfLastRef();
} else {
emit resultsReady(info);