diff options
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 37 | ||||
-rw-r--r-- | src/corelib/kernel/qobject.h | 8 |
2 files changed, 41 insertions, 4 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index d7cc0bce46..21a74748b5 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3941,7 +3941,7 @@ QList<QByteArray> QObject::dynamicPropertyNames() const QObject debugging output routines. *****************************************************************************/ -static void dumpRecursive(int level, QObject *object) +static void dumpRecursive(int level, const QObject *object) { if (object) { QByteArray buf; @@ -3974,6 +3974,9 @@ static void dumpRecursive(int level, QObject *object) } /*! + \overload + \obsolete + Dumps a tree of children to the debug output. \sa dumpObjectInfo() @@ -3981,10 +3984,26 @@ static void dumpRecursive(int level, QObject *object) void QObject::dumpObjectTree() { + const_cast<const QObject *>(this)->dumpObjectTree(); +} + +/*! + Dumps a tree of children to the debug output. + + \note before Qt 5.9, this function was not const. + + \sa dumpObjectInfo() +*/ + +void QObject::dumpObjectTree() const +{ dumpRecursive(0, this); } /*! + \overload + \obsolete + Dumps information about signal connections, etc. for this object to the debug output. @@ -3993,10 +4012,24 @@ void QObject::dumpObjectTree() void QObject::dumpObjectInfo() { + const_cast<const QObject *>(this)->dumpObjectInfo(); +} + +/*! + Dumps information about signal connections, etc. for this object + to the debug output. + + \note before Qt 5.9, this function was not const. + + \sa dumpObjectTree() +*/ + +void QObject::dumpObjectInfo() const +{ qDebug("OBJECT %s::%s", metaObject()->className(), objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data()); - Q_D(QObject); + Q_D(const QObject); QMutexLocker locker(signalSlotLock(this)); // first, look for connections where this object is the sender diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 3cec9802dc..75a7f63fbf 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -375,8 +375,12 @@ public: #endif //Q_QDOC - void dumpObjectTree(); - void dumpObjectInfo(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + void dumpObjectTree(); // ### Qt 6: remove + void dumpObjectInfo(); // ### Qt 6: remove +#endif + void dumpObjectTree() const; + void dumpObjectInfo() const; #ifndef QT_NO_PROPERTIES bool setProperty(const char *name, const QVariant &value); |