summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2012-11-28 13:00:45 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-28 09:04:59 (GMT)
commit8233a15a7480ed0a5fe9a7500ac3cf54f0e63887 (patch)
treed39689a0aec7ceb9d4eaff935156a869eb78591c /tests/auto
parentb3828295fdbfb684591795ca23d846d3e6126c0b (diff)
downloadQt-8233a15a7480ed0a5fe9a7500ac3cf54f0e63887.zip
Qt-8233a15a7480ed0a5fe9a7500ac3cf54f0e63887.tar.gz
Qt-8233a15a7480ed0a5fe9a7500ac3cf54f0e63887.tar.bz2
QMdi: Don't emit subWindowActivated during StyleChange handling.
The handling of StyleChange de-maximizes the child window temporarily, which was emitting subWindowActivated. This would crash lokalize, because deactivating a window means deleting the widgets associated with it, and style-change handling is done in QApplication by looping over QApplication::allWidgets, which would then contain dangling pointers. Full valgrind log at https://bugs.kde.org/show_bug.cgi?id=271494#c7 Change-Id: I256da214bf00fd7925dcee67b4f0414e57fc453b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> (cherry picked from qtbase/a6e5ccbe223c5a606e15556e8708e863442d9f72)
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
index 928e2c6..e672ce9 100644
--- a/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -163,6 +163,7 @@ Q_DECLARE_METATYPE(Qt::WindowState);
Q_DECLARE_METATYPE(Qt::WindowStates);
Q_DECLARE_METATYPE(Qt::WindowType);
Q_DECLARE_METATYPE(Qt::WindowFlags);
+Q_DECLARE_METATYPE(QMdiSubWindow*);
//TESTED_CLASS=
//TESTED_FILES=
@@ -214,6 +215,7 @@ private slots:
void task_182852();
void task_233197();
void task_226929();
+ void styleChange();
};
void tst_QMdiSubWindow::initTestCase()
@@ -2039,6 +2041,38 @@ void tst_QMdiSubWindow::task_226929()
QVERIFY(sub1->isMaximized());
}
+void tst_QMdiSubWindow::styleChange()
+{
+ QMdiArea mdiArea;
+ mdiArea.show();
+
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&mdiArea);
+#endif
+
+ QMdiSubWindow *sub1 = mdiArea.addSubWindow(new QTextEdit);
+ sub1->showMaximized();
+
+ QMdiSubWindow *sub2 = mdiArea.addSubWindow(new QTextEdit);
+ sub2->showMinimized();
+
+ mdiArea.setActiveSubWindow(sub1);
+
+ QTest::qWait(100);
+
+ qRegisterMetaType<QMdiSubWindow *>();
+ QSignalSpy spy(&mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)));
+ QVERIFY(spy.isValid());
+
+ QEvent event(QEvent::StyleChange);
+ QApplication::sendEvent(sub1, &event);
+ QApplication::sendEvent(sub2, &event);
+
+ // subWindowActivated should NOT be activated by a style change,
+ // even if internally QMdiSubWindow un-minimizes subwindows temporarily.
+ QCOMPARE(spy.count(), 0);
+}
+
QTEST_MAIN(tst_QMdiSubWindow)
#include "tst_qmdisubwindow.moc"