Made tst_QWidget::winIdChangeEvent() pass with Lighthouse.
authorSamuel Rødal <samuel.rodal@nokia.com>
Fri, 3 Jun 2011 07:57:57 +0000 (09:57 +0200)
committerSamuel Rødal <samuel.rodal@nokia.com>
Fri, 3 Jun 2011 08:00:25 +0000 (10:00 +0200)
We need to call setWinId() at appropriate times, and enable creation of
native handles for child widgets when createWinId() is called.

src/widgets/kernel/qwidget.cpp
src/widgets/kernel/qwidget_qpa.cpp

index 83eec1e..5788805 100644 (file)
@@ -2474,9 +2474,7 @@ WId QWidget::winId() const
         qDebug() << "QWidget::winId: creating native window for" << this;
 #endif
         QWidget *that = const_cast<QWidget*>(this);
-#ifndef Q_WS_QPA
         that->setAttribute(Qt::WA_NativeWindow);
-#endif
         that->d_func()->createWinId();
         return that->data->winid;
     }
index ebd6180..ccfec7c 100644 (file)
@@ -184,6 +184,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
     Q_Q(QWidget);
 
     Qt::WindowFlags oldFlags = data.window_flags;
+    bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
 
     int targetScreen = -1;
     // Handle a request to move the widget to a particular screen
@@ -196,6 +197,8 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
         newparent = 0;
     }
 
+    setWinId(0);
+
     if (parent != newparent) {
         QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function???
         if (q->windowHandle()) {
@@ -231,6 +234,8 @@ 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 (wasCreated) {
+        q->createWinId();
     }
 
     adjustFlags(f, q);