diff options
| author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-10-14 13:00:02 +0200 |
|---|---|---|
| committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-10-14 19:19:38 +0200 |
| commit | e95e9c28f07e22ea76a7a5521c090a785133dbfd (patch) | |
| tree | 2c416de87604cc1a15286a7385dbc4004d2a27f0 | |
| parent | c179549a7402d70ed4be5ab3af5939667f4238a1 (diff) | |
QWidget: Don't rely on topextra to determine if window is top level
Doing so results in bailing out early for a widget that hasn't been
shown yet, or otherwise resulted in creating extra and topextra,
which means the normalGeometry will not reflect the widget's geometry.
Pick-to: 6.2
Change-Id: Ieb85e9a6109ae34fe20d79e3c12f4517f827a590
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
| -rw-r--r-- | src/widgets/kernel/qwidget.cpp | 2 | ||||
| -rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 2534a7aeba1..d5a0e92fac5 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -3668,7 +3668,7 @@ QPoint QWidget::pos() const QRect QWidget::normalGeometry() const { Q_D(const QWidget); - if (!d->extra || !d->extra->topextra) + if (!isWindow()) return QRect(); if (!isMaximized() && !isFullScreen()) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 00350c3946b..a79c4aed8c2 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -3172,6 +3172,7 @@ void tst_QWidget::normalGeometry() if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); QWidget parent; + QCOMPARE(parent.normalGeometry(), parent.geometry()); parent.setWindowTitle("NormalGeometry parent"); QWidget *child = new QWidget(&parent); |
