summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qobject.cpp25
-rw-r--r--src/corelib/kernel/qobject_p.h4
-rw-r--r--src/widgets/kernel/qwidget.cpp21
-rw-r--r--src/widgets/kernel/qwidget_p.h2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp40
5 files changed, 75 insertions, 17 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 116b080b21..70f98e8324 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4202,27 +4202,18 @@ QList<QByteArray> QObject::dynamicPropertyNames() const
QObject debugging output routines.
*****************************************************************************/
+std::string QObjectPrivate::flagsForDumping() const
+{
+ return {};
+}
+
static void dumpRecursive(int level, const QObject *object)
{
if (object) {
const int indent = level * 4;
- const QString name = object->objectName();
- QString flags;
-#if 0
- if (qApp->focusWidget() == object)
- flags += 'F';
- if (object->isWidgetType()) {
- QWidget * w = (QWidget *)object;
- if (w->isVisible()) {
- QString t("<%1,%2,%3,%4>");
- flags += t.arg(w->x()).arg(w->y()).arg(w->width()).arg(w->height());
- } else {
- flags += 'I';
- }
- }
-#endif
- qDebug("%*s%s::%ls %ls", indent, "", object->metaObject()->className(),
- qUtf16Printable(name), qUtf16Printable(flags));
+ qDebug("%*s%s::%ls %s", indent, "", object->metaObject()->className(),
+ qUtf16Printable(object->objectName()),
+ QObjectPrivate::get(object)->flagsForDumping().c_str());
for (auto child : object->children())
dumpRecursive(level + 1, child);
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 149c6a03a6..d98c7065f0 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -63,6 +63,8 @@
#include "QtCore/qproperty.h"
#include "QtCore/private/qproperty_p.h"
+#include <string>
+
QT_BEGIN_NAMESPACE
class QVariant;
@@ -412,6 +414,8 @@ public:
connections.storeRelaxed(cd);
}
+ virtual std::string flagsForDumping() const;
+
public:
mutable ExtraData *extraData; // extra data set by the user
// This atomic requires acquire/release semantics in a few places,
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 3918a46da4..97a02899f8 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -110,6 +110,8 @@
#include "qwindowcontainer_p.h"
+#include <sstream>
+
// widget/widget data creation count
//#define QWIDGET_EXTRA_DEBUG
//#define ALIEN_DEBUG
@@ -12961,6 +12963,25 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new
widget->setParent(static_cast<QWidget*>(newParent));
}
+std::string QWidgetPrivate::flagsForDumping() const
+{
+ Q_Q(const QWidget);
+ std::string flags = QObjectPrivate::flagsForDumping();
+ if (QApplication::focusWidget() == q)
+ flags += 'F';
+ if (q->isVisible()) {
+ std::stringstream s;
+ s << '<'
+ << q->width() << 'x' << q->height()
+ << std::showpos << q->x() << q->y()
+ << '>';
+ flags += s.str();
+ } else {
+ flags += 'I';
+ }
+ return flags;
+}
+
void QWidgetPrivate::setNetWmWindowTypes(bool skipIfMissing)
{
#if QT_CONFIG(xcb)
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index b8a30fde25..a6af19b030 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -663,6 +663,8 @@ public:
static void setWidgetParentHelper(QObject *widgetAsObject, QObject *newParent);
+ std::string flagsForDumping() const override;
+
// Variables.
// Regular pointers (keep them together to avoid gaps on 64 bit architectures).
std::unique_ptr<QWExtra> extra;
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index ea0d5e8871..040ad17c74 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -335,6 +335,8 @@ private slots:
void resizeInPaintEvent();
void opaqueChildren();
+ void dumpObjectTree();
+
void setMaskInResizeEvent();
void moveInResizeEvent();
@@ -9060,6 +9062,44 @@ void tst_QWidget::opaqueChildren()
QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), QRegion());
}
+void tst_QWidget::dumpObjectTree()
+{
+ QWidget w;
+ w.setWindowTitle(QLatin1String(QTest::currentTestFunction()));
+ Q_SET_OBJECT_NAME(w);
+ w.move(100, 100);
+ w.resize(500, 500);
+
+ QLineEdit le(&w);
+ Q_SET_OBJECT_NAME(le);
+ le.resize(500, 500);
+
+ {
+ const char * const expected[] = {
+ "QWidget::w I",
+ " QLineEdit::le I",
+ " QWidgetLineControl:: ",
+ };
+ for (const char *line : expected)
+ QTest::ignoreMessage(QtDebugMsg, line);
+ w.dumpObjectTree();
+ }
+
+ w.show();
+ QApplication::setActiveWindow(&w);
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+
+ {
+ const char * const expected[] = {
+ "QWidget::w <500x500+100+100>",
+ " QLineEdit::le F<500x500+0+0>",
+ " QWidgetLineControl:: ",
+ };
+ for (const char *line : expected)
+ QTest::ignoreMessage(QtDebugMsg, line);
+ w.dumpObjectTree();
+ }
+}
class MaskSetWidget : public QWidget
{