qpa: Verify that the platform returns a WId that is not WId(0)
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>
Wed, 1 Feb 2012 12:32:53 +0000 (13:32 +0100)
committerQt by Nokia <qt-info@nokia.com>
Mon, 20 Feb 2012 08:36:51 +0000 (09:36 +0100)
This is motivated by visiting a customer that re-implemented the
::winId method and returned WId(0) that resulted in a crash. Currently
there is only a comment inside the implementation of the ::winId
default implementation. Add a note to the API documentation, add
a Q_ASSERT to check if our assumption holds true.

Change-Id: I8607a4efc4f561f7849c976cd2454f6fbcb20eaa
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/gui/kernel/qwindow.cpp

index 5b6ee0e..85f12dd 100644 (file)
@@ -220,7 +220,11 @@ WId QWindow::winId() const
     Q_D(const QWindow);
     if(!d->platformWindow)
         const_cast<QWindow *>(this)->create();
-    return d->platformWindow->winId();
+
+    WId id = d->platformWindow->winId();
+    // See the QPlatformWindow::winId() documentation
+    Q_ASSERT(id != WId(0));
+    return id;
 }
 
 QWindow *QWindow::parent() const