QObject: restore flags printing in dumpObjectTree()
This was lost when QtCore, QtGui and QtWidgets were split up. Restored now via a virtual function on QObjectPrivate. Chose to return std::string instead of QString or QByteArray because its SSO is usually sufficient to hold these flag strings. [ChangeLog][QtCore][QObject] Restored printing of Qt3-style information from dumpObjectTree(). [ChangeLog][QtWidgets][QWidget] Restored printing of Qt3-style information from QWidget::dumpObjectTree(). Fixes: QTBUG-101732 Change-Id: I39ff5728ea5f5abbdbf81b5d7e13b8d16b6ee8b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
6ec1dc904d
commit
f97daab7a6
@ -4202,27 +4202,18 @@ QList<QByteArray> QObject::dynamicPropertyNames() const
|
|||||||
QObject debugging output routines.
|
QObject debugging output routines.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
std::string QObjectPrivate::flagsForDumping() const
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
static void dumpRecursive(int level, const QObject *object)
|
static void dumpRecursive(int level, const QObject *object)
|
||||||
{
|
{
|
||||||
if (object) {
|
if (object) {
|
||||||
const int indent = level * 4;
|
const int indent = level * 4;
|
||||||
const QString name = object->objectName();
|
qDebug("%*s%s::%ls %s", indent, "", object->metaObject()->className(),
|
||||||
QString flags;
|
qUtf16Printable(object->objectName()),
|
||||||
#if 0
|
QObjectPrivate::get(object)->flagsForDumping().c_str());
|
||||||
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));
|
|
||||||
for (auto child : object->children())
|
for (auto child : object->children())
|
||||||
dumpRecursive(level + 1, child);
|
dumpRecursive(level + 1, child);
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,8 @@
|
|||||||
#include "QtCore/qproperty.h"
|
#include "QtCore/qproperty.h"
|
||||||
#include "QtCore/private/qproperty_p.h"
|
#include "QtCore/private/qproperty_p.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QVariant;
|
class QVariant;
|
||||||
@ -412,6 +414,8 @@ public:
|
|||||||
connections.storeRelaxed(cd);
|
connections.storeRelaxed(cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual std::string flagsForDumping() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
mutable ExtraData *extraData; // extra data set by the user
|
mutable ExtraData *extraData; // extra data set by the user
|
||||||
// This atomic requires acquire/release semantics in a few places,
|
// This atomic requires acquire/release semantics in a few places,
|
||||||
|
@ -110,6 +110,8 @@
|
|||||||
|
|
||||||
#include "qwindowcontainer_p.h"
|
#include "qwindowcontainer_p.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
// widget/widget data creation count
|
// widget/widget data creation count
|
||||||
//#define QWIDGET_EXTRA_DEBUG
|
//#define QWIDGET_EXTRA_DEBUG
|
||||||
//#define ALIEN_DEBUG
|
//#define ALIEN_DEBUG
|
||||||
@ -12961,6 +12963,25 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new
|
|||||||
widget->setParent(static_cast<QWidget*>(newParent));
|
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)
|
void QWidgetPrivate::setNetWmWindowTypes(bool skipIfMissing)
|
||||||
{
|
{
|
||||||
#if QT_CONFIG(xcb)
|
#if QT_CONFIG(xcb)
|
||||||
|
@ -663,6 +663,8 @@ public:
|
|||||||
|
|
||||||
static void setWidgetParentHelper(QObject *widgetAsObject, QObject *newParent);
|
static void setWidgetParentHelper(QObject *widgetAsObject, QObject *newParent);
|
||||||
|
|
||||||
|
std::string flagsForDumping() const override;
|
||||||
|
|
||||||
// Variables.
|
// Variables.
|
||||||
// Regular pointers (keep them together to avoid gaps on 64 bit architectures).
|
// Regular pointers (keep them together to avoid gaps on 64 bit architectures).
|
||||||
std::unique_ptr<QWExtra> extra;
|
std::unique_ptr<QWExtra> extra;
|
||||||
|
@ -335,6 +335,8 @@ private slots:
|
|||||||
void resizeInPaintEvent();
|
void resizeInPaintEvent();
|
||||||
void opaqueChildren();
|
void opaqueChildren();
|
||||||
|
|
||||||
|
void dumpObjectTree();
|
||||||
|
|
||||||
void setMaskInResizeEvent();
|
void setMaskInResizeEvent();
|
||||||
void moveInResizeEvent();
|
void moveInResizeEvent();
|
||||||
|
|
||||||
@ -9060,6 +9062,44 @@ void tst_QWidget::opaqueChildren()
|
|||||||
QCOMPARE(qt_widget_private(&grandChild)->getOpaqueChildren(), QRegion());
|
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
|
class MaskSetWidget : public QWidget
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user