Simplify tst_QWidget::closeAndShowWithNativeChild

The nativeHiddenChild is not used for anything, and shouldn't be
needed to trigger the failure condition.

That said, I was not able to reproduce the test failure on macOS
14 with the test neither pre or post patch, nor with any of the
test cases mentioned in 51300566ffe2ece2455e1d0479a556c5dbb3bb8e,
nor with 51300566ffe2ece2455e1d0479a556c5dbb3bb8e itself, so this
has seemingly been fixed or worked around some other way in the
meantime.

Task-number: QTBUG-121398
Change-Id: I299e7f4b71ebdb17870348a3d5b0c49a93228c8b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit f85c988980f73398762d4bd5c1a8a1799d182bdd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-01-18 16:55:05 +01:00 committed by Qt Cherry-pick Bot
parent 0b76a0b322
commit c8a543e3ec

View File

@ -5429,24 +5429,29 @@ void tst_QWidget::closeAndShowWithNativeChild()
QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
QWidget topLevel;
topLevel.setObjectName("TopLevel");
QWidget *nativeChild = new QWidget;
nativeChild->setObjectName("NativeChild");
nativeChild->setFixedSize(200, 200);
QWidget *nativeHiddenChild = new QWidget;
nativeHiddenChild->setFixedSize(200, 200);
QWidget *normalChild = new QWidget;
normalChild->setObjectName("NormalChild");
normalChild->setFixedSize(200, 200);
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(nativeChild);
layout->addWidget(nativeHiddenChild);
layout->addWidget(normalChild);
topLevel.setLayout(layout);
nativeHiddenChild->hide();
nativeChild->setAttribute(Qt::WA_NativeWindow);
QCOMPARE(normalChild->testAttribute(Qt::WA_WState_Hidden), false);
QCOMPARE(normalChild->testAttribute(Qt::WA_WState_ExplicitShowHide), false);
QCOMPARE(nativeChild->testAttribute(Qt::WA_WState_Hidden), false);
QCOMPARE(nativeChild->testAttribute(Qt::WA_WState_ExplicitShowHide), false);
topLevel.show();
QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
nativeChild->winId();
const QSize originalSize = topLevel.size();
topLevel.close();