diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 67ea378c66..9e8e1eac11 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -1602,6 +1602,23 @@ void tst_QWindow::sizes() QCOMPARE(maximumHeightSpy.count(), 1); } +class CloseOnCloseEventWindow : public QWindow +{ +public: + inline static int closeEvents; + CloseOnCloseEventWindow() { closeEvents = 0; } + +protected: + void closeEvent(QCloseEvent *e) override + { + if (++closeEvents > 1) + return; + + close(); + e->accept(); + } +}; + void tst_QWindow::close() { { @@ -1683,6 +1700,16 @@ void tst_QWindow::close() QVERIFY(c.handle()); } } + + { + // A QWidget will call close() from the destructor, and + // we allow widgets deleting itself in the closeEvent, + // so we need to guard against close being called recursively. + CloseOnCloseEventWindow w; + w.create(); + w.close(); + QCOMPARE(CloseOnCloseEventWindow::closeEvents, 1); + } } void tst_QWindow::activateAndClose() |