Fix rendering glitches when using native widgets in MDI subwindows
authorMiikka Heikkinen <miikka.heikkinen@digia.com>
Tue, 17 Jul 2012 13:35:38 +0000 (16:35 +0300)
committerQt by Nokia <qt-info@nokia.com>
Wed, 18 Jul 2012 13:07:32 +0000 (15:07 +0200)
When mixing native and regular widgets in same QMdiArea, some
subwindows didn't properly get set native. This was because
when a native parentless widget was given a parent, it wouldn't
enforce native window on the new parent and its ancestors.
This happened because window flags were adjusted too late in
relation to createWinId() call in setParent_sys().
Fixed by moving the createWinId() call to its proper place.

Also removed some old Q_WS_* ifdeffing in QWidget::setParent() that
masked some native enforcement code.

Additionally removed few QEXPECT_FAILs from QWidget autotest now
that those cases work correctly.

Task-number: QTBUG-26424
Change-Id: Ib6f9d0531e5c7299e2c307734d49c81f1ffa9713
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/widgets/kernel/qwidget.cpp
src/widgets/kernel/qwidget_qpa.cpp
tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp

index ca5a410..747d0a0 100644 (file)
@@ -9486,7 +9486,6 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
         desktopWidget = parent;
     bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
 
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC)
     if (newParent && parent && !desktopWidget) {
         if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)
 #ifdef Q_WS_MAC
@@ -9499,7 +9498,6 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
         else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
             setAttribute(Qt::WA_NativeWindow);
     }
-#endif
 
     if (wasCreated) {
         if (!testAttribute(Qt::WA_WState_Hidden)) {
index 3661a08..5b3155f 100644 (file)
@@ -259,8 +259,6 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
     if (!(f&Qt::Window) && (oldFlags&Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
         //qDebug() << "setParent_sys() change from toplevel";
         q->destroy();
-    } else if (newparent && wasCreated) {
-        q->createWinId();
     }
 
     adjustFlags(f, q);
@@ -269,6 +267,9 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
     q->setAttribute(Qt::WA_WState_Visible, false);
     q->setAttribute(Qt::WA_WState_Hidden, false);
 
+    if (newparent && wasCreated && (q->testAttribute(Qt::WA_NativeWindow) || (f & Qt::Window)))
+        q->createWinId();
+
     if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
         q->setAttribute(Qt::WA_WState_Hidden);
     q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
index 8d6ef38..caaabe0 100644 (file)
@@ -7174,14 +7174,8 @@ void tst_QWidget::alienWidgets()
 
         topLevel.show();
         QVERIFY(topLevel.internalWinId());
-        if (m_platform == QStringLiteral("xcb") || m_platform == QStringLiteral("windows"))
-            QEXPECT_FAIL("", "QTBUG-26424", Continue);
         QVERIFY(widget->testAttribute(Qt::WA_NativeWindow));
-        if (m_platform == QStringLiteral("xcb") || m_platform == QStringLiteral("windows"))
-            QEXPECT_FAIL("", "QTBUG-26424", Continue);
         QVERIFY(child->internalWinId());
-        if (m_platform == QStringLiteral("xcb") || m_platform == QStringLiteral("windows"))
-            QEXPECT_FAIL("", "QTBUG-26424", Continue);
         QVERIFY(child->testAttribute(Qt::WA_NativeWindow));
         QVERIFY(!child->testAttribute(Qt::WA_PaintOnScreen));
         QVERIFY(!dummy->internalWinId());