QMetaObject: port invokeMethodImpl() from QScopeGuard to SlotObjUniquePtr
... so it can use the new QMetaCallEvent() ctors taking that type. As a consequence, the slot object ref-count is now no longer touched on the way into the meta-call event (was: upped in QMetaCallEvent ctor, then downed in QScopeGuard). Manual conflict resolutions: - QScopeGuard -> custom Holder struct Change-Id: Id9bd157792458a3834809c23e94ca5f504f7abd1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 4015f81d31d783549bfe0bd26ab1504789e056fe) Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
4395e1e06b
commit
5078becc41
@ -1611,13 +1611,10 @@ bool QMetaObject::invokeMethodImpl(QObject *obj, const char *member, Qt::Connect
|
|||||||
return printMethodNotFoundWarning(obj->metaObject(), name, paramCount, typeNames, metaTypes);
|
return printMethodNotFoundWarning(obj->metaObject(), name, paramCount, typeNames, metaTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *slot, Qt::ConnectionType type, void *ret)
|
bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *slotObj,
|
||||||
|
Qt::ConnectionType type, void *ret)
|
||||||
{
|
{
|
||||||
struct Holder {
|
auto slot = QtPrivate::SlotObjUniquePtr(slotObj);
|
||||||
QtPrivate::QSlotObjectBase *obj;
|
|
||||||
~Holder() { obj->destroyIfLastRef(); }
|
|
||||||
} holder = { slot };
|
|
||||||
Q_UNUSED(holder);
|
|
||||||
|
|
||||||
if (! object)
|
if (! object)
|
||||||
return false;
|
return false;
|
||||||
@ -1642,14 +1639,14 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QCoreApplication::postEvent(object, new QMetaCallEvent(slot, nullptr, -1, 1));
|
QCoreApplication::postEvent(object, new QMetaCallEvent(std::move(slot), nullptr, -1, 1));
|
||||||
} else if (type == Qt::BlockingQueuedConnection) {
|
} else if (type == Qt::BlockingQueuedConnection) {
|
||||||
#if QT_CONFIG(thread)
|
#if QT_CONFIG(thread)
|
||||||
if (receiverInSameThread)
|
if (receiverInSameThread)
|
||||||
qWarning("QMetaObject::invokeMethod: Dead lock detected");
|
qWarning("QMetaObject::invokeMethod: Dead lock detected");
|
||||||
|
|
||||||
QSemaphore semaphore;
|
QSemaphore semaphore;
|
||||||
QCoreApplication::postEvent(object, new QMetaCallEvent(slot, nullptr, -1, argv, &semaphore));
|
QCoreApplication::postEvent(object, new QMetaCallEvent(std::move(slot), nullptr, -1, argv, &semaphore));
|
||||||
semaphore.acquire();
|
semaphore.acquire();
|
||||||
#endif // QT_CONFIG(thread)
|
#endif // QT_CONFIG(thread)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user