QObject::dumpObject*: enable them also for non-debug builds

It makes very little sense that one needs to have a debug build
of Qt to debug QObject issues in application code. At this date
we don't even offer debug builds for Linux systems, and anyhow
one might want to debug an application running against a
release build of Qt.

[ChangeLog][QtCore][QObject] QObject::dumpObjectInfo and
QObject::dumpObjectTree are now fully functional even in a non-debug
build of Qt.

Change-Id: Ifddd3023ffc82f3dc3928a7a94d4970e2fb1b44a
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Giuseppe D'Angelo 2016-08-17 20:08:50 +02:00
parent 7f14ad08bb
commit 8e5cd8017e
2 changed files with 0 additions and 17 deletions

View File

@ -3943,7 +3943,6 @@ QList<QByteArray> QObject::dynamicPropertyNames() const
static void dumpRecursive(int level, QObject *object) static void dumpRecursive(int level, QObject *object)
{ {
#if defined(QT_DEBUG)
if (object) { if (object) {
QByteArray buf; QByteArray buf;
buf.fill(' ', level / 2 * 8); buf.fill(' ', level / 2 * 8);
@ -3972,19 +3971,11 @@ static void dumpRecursive(int level, QObject *object)
dumpRecursive(level+1, children.at(i)); dumpRecursive(level+1, children.at(i));
} }
} }
#else
Q_UNUSED(level)
Q_UNUSED(object)
#endif
} }
/*! /*!
Dumps a tree of children to the debug output. Dumps a tree of children to the debug output.
This function is useful for debugging, but does nothing if the
library has been compiled in release mode (i.e. without debugging
information).
\sa dumpObjectInfo() \sa dumpObjectInfo()
*/ */
@ -3997,16 +3988,11 @@ void QObject::dumpObjectTree()
Dumps information about signal connections, etc. for this object Dumps information about signal connections, etc. for this object
to the debug output. to the debug output.
This function is useful for debugging, but does nothing if the
library has been compiled in release mode (i.e. without debugging
information).
\sa dumpObjectTree() \sa dumpObjectTree()
*/ */
void QObject::dumpObjectInfo() void QObject::dumpObjectInfo()
{ {
#if defined(QT_DEBUG)
qDebug("OBJECT %s::%s", metaObject()->className(), qDebug("OBJECT %s::%s", metaObject()->className(),
objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data()); objectName().isEmpty() ? "unnamed" : objectName().toLocal8Bit().data());
@ -4066,7 +4052,6 @@ void QObject::dumpObjectInfo()
} else { } else {
qDebug(" <None>"); qDebug(" <None>");
} }
#endif
} }
#ifndef QT_NO_USERDATA #ifndef QT_NO_USERDATA

View File

@ -3401,14 +3401,12 @@ void tst_QObject::dumpObjectInfo()
QObject a, b; QObject a, b;
QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater())); QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater()));
a.disconnect(&b); a.disconnect(&b);
#ifdef QT_DEBUG
QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed"); QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT"); QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT");
QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)"); QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)");
QTest::ignoreMessage(QtDebugMsg, " <Disconnected receiver>"); QTest::ignoreMessage(QtDebugMsg, " <Disconnected receiver>");
QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN"); QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN");
QTest::ignoreMessage(QtDebugMsg, " <None>"); QTest::ignoreMessage(QtDebugMsg, " <None>");
#endif
a.dumpObjectInfo(); // should not crash a.dumpObjectInfo(); // should not crash
} }