From 0bc96d1d6ba29c6e0a4c39cc526d9515036b7453 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 12 Jun 2013 12:52:31 +0200 Subject: Widgets: Do not create QWindow in createTLExtra(). QWidget::setWindowIcon() and similar call createTLExtra() which creates a QWindow without setting the native attributes on the parent, which can cause crashes when setParent_sys() decides to delete the window. Task-number: QTBUG-31672 Change-Id: I4c40ee12741be88b2281df90329ffb698d4009eb Reviewed-by: Shawn Rutledge --- src/widgets/kernel/qwidget.cpp | 5 ++++- src/widgets/kernel/qwidget_qpa.cpp | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index cfccce7c41..f67a93c7b5 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1546,10 +1546,11 @@ void QWidgetPrivate::createTLExtra() x->inTopLevelResize = false; x->inRepaint = false; x->embedded = 0; + x->window = 0; + x->screenIndex = 0; #ifdef Q_WS_MAC x->wasMaximized = false; #endif // Q_WS_MAC - createTLSysExtra(); #ifdef QWIDGET_EXTRA_DEBUG static int count = 0; qDebug() << "tlextra" << ++count; @@ -10109,6 +10110,8 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) break; } case Qt::WA_NativeWindow: { d->createTLExtra(); + if (on) + d->createTLSysExtra(); #ifndef QT_NO_IM QWidget *focusWidget = d->effectiveFocusWidget(); if (on && !internalWinId() && hasFocus() diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 3b6c9ca448..dafe7dc42a 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -890,9 +890,7 @@ void QWidgetPrivate::deleteSysExtra() void QWidgetPrivate::createTLSysExtra() { Q_Q(QWidget); - extra->topextra->screenIndex = 0; - extra->topextra->window = 0; - if (q->testAttribute(Qt::WA_NativeWindow) || q->isWindow()) { + if (!extra->topextra->window && (q->testAttribute(Qt::WA_NativeWindow) || q->isWindow())) { extra->topextra->window = new QWidgetWindow(q); if (extra->minw || extra->minh) extra->topextra->window->setMinimumSize(QSize(extra->minw, extra->minh)); -- cgit v1.2.3