From a6e5ccbe223c5a606e15556e8708e863442d9f72 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 28 Nov 2012 14:00:45 +0100 Subject: 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: Ifb24032cde2cd470dcae7cd553ec5ab45a919dd6 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qmdisubwindow.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/widgets/widgets/qmdisubwindow.cpp') diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index 4259f75097..b38dea074f 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -164,6 +164,7 @@ #include #endif #include +#include QT_BEGIN_NAMESPACE @@ -2789,6 +2790,10 @@ bool QMdiSubWindow::event(QEvent *event) bool wasShaded = isShaded(); bool wasMinimized = isMinimized(); bool wasMaximized = isMaximized(); + // Don't emit subWindowActivated, the app doesn't have to know about our hacks + const QScopedValueRollback activationEnabledSaver(d->activationEnabled); + d->activationEnabled = false; + ensurePolished(); setContentsMargins(0, 0, 0, 0); if (wasMinimized || wasMaximized || wasShaded) @@ -3008,7 +3013,8 @@ void QMdiSubWindow::changeEvent(QEvent *changeEvent) if (d->isActive) d->ensureWindowState(Qt::WindowActive); - emit windowStateChanged(oldState, windowState()); + if (d->activationEnabled) + emit windowStateChanged(oldState, windowState()); } /*! -- cgit v1.2.3