Commit e342a2e0 authored by Gabriel de Dietrich's avatar Gabriel de Dietrich Committed by Morten Johan Sørvig
Browse files

Add auto-test for crash in QCocoaBackingStore


This issue has been solved some time between 5.6 and 5.6.0.
We just make sure to protect against further regressions.

Change-Id: Ic3fdad901ed5f36792ae04b3d65047da95eea668
Task-number: QTBUG-50561
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>
parent e9dedb68
Branches
Tags
No related merge requests found
Showing with 45 additions and 0 deletions
......@@ -46,6 +46,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)
......@@ -99,6 +101,8 @@ private slots:
void tst_move_count();
void tst_eventfilter_on_toplevel();
void QTBUG_50561_QCocoaBackingStore_paintDevice_crash();
};
void tst_QWidget_window::initTestCase()
......@@ -795,5 +799,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"
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment