From 062be102283d39bf0cc2b49fbc2e21d48f79ea42 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 6 Dec 2016 11:59:50 +0100 Subject: [PATCH] Mark qt_addObject/qt_removeObject for removal in Qt6 We now have qtHookData, which is a better (and cheaper) way to add hooks for object creation and deletion. For binary-compatibility reasons we cannot remove it in Qt5. Change-Id: Iecd9f4e1195f90279c395845fa26c6301b67b9a1 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qobject.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 4ae886150f4..fd1c767b4c7 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -147,12 +147,13 @@ static inline QMutex *signalSlotLock(const QObject *o) uint(quintptr(o)) % sizeof(_q_ObjectMutexPool)/sizeof(QBasicMutex)]); } -// ### Qt >= 5.6, remove qt_add/removeObject +#if QT_VERSION < 0x60000 extern "C" Q_CORE_EXPORT void qt_addObject(QObject *) {} extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) {} +#endif struct QConnectionSenderSwitcher { QObject *receiver; @@ -811,7 +812,9 @@ QObject::QObject(QObject *parent) QT_RETHROW; } } +#if QT_VERSION < 0x60000 qt_addObject(this); +#endif if (Q_UNLIKELY(qtHookData[QHooks::AddQObject])) reinterpret_cast(qtHookData[QHooks::AddQObject])(this); } @@ -844,7 +847,9 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent) QT_RETHROW; } } +#if QT_VERSION < 0x60000 qt_addObject(this); +#endif if (Q_UNLIKELY(qtHookData[QHooks::AddQObject])) reinterpret_cast(qtHookData[QHooks::AddQObject])(this); } @@ -1016,7 +1021,9 @@ QObject::~QObject() if (!d->children.isEmpty()) d->deleteChildren(); +#if QT_VERSION < 0x60000 qt_removeObject(this); +#endif if (Q_UNLIKELY(qtHookData[QHooks::RemoveQObject])) reinterpret_cast(qtHookData[QHooks::RemoveQObject])(this);