summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-04-24 19:17:45 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-04-27 07:00:13 +0000
commite0b5ff4ad583befbecbcbe462998e3ed80899531 (patch)
treecc55352d7b8d16d380924d48bd93abd858374bbe /tests
parente69b6d2dbc9166f07ff3ee1e588f39d244c0b692 (diff)
QWidgetWindow: Immediately forward close events to QWindow
This way the platform window is destroyed in a timely manner, preventing redundant close events from the window system. Task-number: QTBUG-43344 Change-Id: Ifdfca59ceacef54405f1c227c493dc514a1b27ea Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 823a52ce70..47ffee1501 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -401,6 +401,8 @@ private slots:
void tabletTracking();
+ void closeEvent();
+
private:
bool ensureScreenSize(int width, int height);
@@ -10798,5 +10800,31 @@ void tst_QWidget::tabletTracking()
QTRY_COMPARE(widget.moveEventCount, 3);
}
+class CloseCountingWidget : public QWidget
+{
+public:
+ int closeCount = 0;
+ void closeEvent(QCloseEvent *ev) override;
+};
+
+void CloseCountingWidget::closeEvent(QCloseEvent *ev)
+{
+ ++closeCount;
+ ev->accept();
+}
+
+void tst_QWidget::closeEvent()
+{
+ CloseCountingWidget widget;
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ // Yes we call the close() function twice. This mimics the behavior of QTBUG-43344 where
+ // QApplication first closes all windows and then QCocoaApplication flushes window system
+ // events, triggering more close events.
+ widget.windowHandle()->close();
+ widget.windowHandle()->close();
+ QCOMPARE(widget.closeCount, 1);
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"