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>
This commit is contained in:
Tor Arne Vestbø 2021-10-14 13:00:02 +02:00
parent c179549a74
commit e95e9c28f0
2 changed files with 2 additions and 1 deletions

View File

@ -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())

View File

@ -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);