summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2013-06-12 12:52:31 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-14 14:40:18 +0200
commit0bc96d1d6ba29c6e0a4c39cc526d9515036b7453 (patch)
tree84648cf632a289e5348ba68f38adf40a1396ec43
parentb6f24423716b82686c86d33828b7139ac717afdd (diff)
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 <shawn.rutledge@digia.com>
-rw-r--r--src/widgets/kernel/qwidget.cpp5
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp4
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));