Port QObjectPrivate::connect() to SlotObjUniquePtr internally

This is for consistency with QObject::connectImpl() and
QObjectPrivate::connectImpl(), if nothing else.

See the commit message of the QObject::connectImpl() porting patch for
why we leave the function signature unchanged (key-word:
tail-callability).

Pick-to: 6.6 6.5
Change-Id: I515d3be4a5126f9f4738dd7bde5174377faf2343
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2023-07-19 21:27:56 +02:00
parent 18857db2dd
commit ff75ace02d

View File

@ -5334,20 +5334,19 @@ QMetaObject::Connection QObjectPrivate::connect(const QObject *sender, int signa
*/
QMetaObject::Connection QObjectPrivate::connect(const QObject *sender, int signal_index,
const QObject *receiver,
QtPrivate::QSlotObjectBase *slotObj,
QtPrivate::QSlotObjectBase *slotObjRaw,
Qt::ConnectionType type)
{
QtPrivate::SlotObjUniquePtr slotObj(slotObjRaw);
if (!sender) {
qCWarning(lcConnect, "QObject::connect: invalid nullptr parameter");
if (slotObj)
slotObj->destroyIfLastRef();
return QMetaObject::Connection();
}
const QMetaObject *senderMetaObject = sender->metaObject();
signal_index = methodIndexToSignalIndex(&senderMetaObject, signal_index);
return QObjectPrivate::connectImpl(sender, signal_index, receiver, /*slot*/ nullptr, slotObj,
type, /*types*/ nullptr, senderMetaObject);
return connectImpl(sender, signal_index, receiver, /*slot*/ nullptr, slotObj.release(),
type, /*types*/ nullptr, senderMetaObject);
}
/*!