diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-03-23 08:29:43 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2016-03-23 08:29:43 +0100 |
commit | 8e2d3e3b90d7d35d2c91fc09ab5a9cccac0823e8 (patch) | |
tree | fe20315ed91d4babd73df69ece0af1d1550cb40c /tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp | |
parent | bf17e30c8e98b311cdee397f1272e70863247ebc (diff) | |
parent | f319b9b43c313dfa306a62c391e767bc6f14bdee (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I9a10e1f3c9506ec8554d8f59b6300825ac730939
Diffstat (limited to 'tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp')
-rw-r--r-- | tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index cd8bce173b..200c8a6ced 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -41,6 +41,8 @@ #include <qboxlayout.h> #include <qtabwidget.h> #include <qlabel.h> +#include <qmainwindow.h> +#include <qtoolbar.h> #include <private/qwindow_p.h> static inline void setFrameless(QWidget *w) @@ -94,6 +96,8 @@ private slots: void tst_move_count(); void tst_eventfilter_on_toplevel(); + + void QTBUG_50561_QCocoaBackingStore_paintDevice_crash(); }; void tst_QWidget_window::initTestCase() @@ -790,5 +794,46 @@ void tst_QWidget_window::tst_eventfilter_on_toplevel() QTRY_COMPARE(filter.eventCount, 1); } +class ApplicationStateSaver +{ +public: + ApplicationStateSaver() + { + QApplication::setAttribute(Qt::AA_NativeWindows, true); + QApplication::setQuitOnLastWindowClosed(false); + } + + ~ApplicationStateSaver() + { + QApplication::setAttribute(Qt::AA_NativeWindows, false); + QApplication::setQuitOnLastWindowClosed(true); + } +}; + +void tst_QWidget_window::QTBUG_50561_QCocoaBackingStore_paintDevice_crash() +{ + // Keep application state clean if testcase fails + ApplicationStateSaver as; + + QMainWindow w; + w.addToolBar(new QToolBar(&w)); + w.show(); + QTest::qWaitForWindowExposed(&w); + + // Simulate window system close + QCloseEvent *e = new QCloseEvent; + e->accept(); + qApp->postEvent(w.windowHandle(), e); + qApp->processEvents(); + + // Show again + w.show(); + qApp->processEvents(); + + // No crash, all good. + // Wrap up and leave + w.close(); +} + QTEST_MAIN(tst_QWidget_window) #include "tst_qwidget_window.moc" |