summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-03 11:48:56 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-23 21:25:46 +0200
commit0d97723ee2778203af0cfd13599572110fb69dd5 (patch)
treede1562da4e76010f6513d3ee4d80f0a867386b3c /tests/auto/widgets/kernel
parent7ec215301612e7d52352738629d64360c48baf28 (diff)
Fix separate delete of window and windowcontainer
The documentation says we can change window parent to avoid the widget deleting the window. That didn't work as the widget didn't get the child-removed event as it wasn't the parent. This patch instead uses an event filter on the set parent. Pick-to: 6.3 6.2 Change-Id: I1f61d1832fcf3257722f305beeefd8f1abf1f656 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests/auto/widgets/kernel')
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 8d0f84ca60..19c9606d79 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -50,6 +50,7 @@ private slots:
void testOwnership();
void testBehindTheScenesDeletion();
void testUnparenting();
+ void testReparenting();
void testUnparentReparent();
void testActivation();
void testAncestorChange();
@@ -206,12 +207,12 @@ void tst_QWindowContainer::testActivation()
void tst_QWindowContainer::testUnparenting()
{
- QWindow *window = new QWindow();
+ QPointer<QWindow> window(new QWindow());
QScopedPointer<QWidget> container(QWidget::createWindowContainer(window));
container->setWindowTitle(QTest::currentTestFunction());
container->setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 200, 100);
- window->setParent(0);
+ window->setParent(nullptr);
container->show();
@@ -219,6 +220,26 @@ void tst_QWindowContainer::testUnparenting()
// Window should not be made visible by container..
QVERIFY(!window->isVisible());
+
+ container.reset();
+ QVERIFY(window);
+ delete window;
+}
+
+void tst_QWindowContainer::testReparenting()
+{
+ QPointer<QWindow> window1(new QWindow());
+ QScopedPointer<QWindow> window2(new QWindow());
+ QScopedPointer<QWidget> container(QWidget::createWindowContainer(window1));
+
+ window1->setParent(window2.data());
+
+ // Not deleted with container
+ container.reset();
+ QVERIFY(window1);
+ // but deleted with new parent
+ window2.reset();
+ QVERIFY(!window1);
}
void tst_QWindowContainer::testUnparentReparent()