Fix QPA xlib plugin handling of setParent(0).
authorBradley Smith <bradley@baysmith.com>
Tue, 13 Dec 2011 05:47:03 +0000 (21:47 -0800)
committerQt by Nokia <qt-info@nokia.com>
Tue, 13 Dec 2011 10:11:58 +0000 (11:11 +0100)
Dereference of the parent argument did not check for nullptr. For
example, the hellogl example would crash. Now if the parent
argument is null, the screen's root window is used.

Change-Id: Ib06181c9ab9794d577722f1c1dd5ee92e4edaee5
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/plugins/platforms/xlib/qxlibwindow.cpp
src/plugins/platforms/xlib/qxlibwindow.h

index c14fada..70eb061 100644 (file)
@@ -303,10 +303,11 @@ WId QXlibWindow::winId() const
     return x_window;
 }
 
-void QXlibWindow::setParent(const QPlatformWindow *window)
+void QXlibWindow::setParent(const QPlatformWindow *parent)
 {
     QPoint topLeft = geometry().topLeft();
-    XReparentWindow(mScreen->display()->nativeDisplay(),x_window,window->winId(),topLeft.x(),topLeft.y());
+    WId parentWinId = parent ? parent->winId() : mScreen->rootWindow();
+    XReparentWindow(mScreen->display()->nativeDisplay(),x_window,parentWinId,topLeft.x(),topLeft.y());
 }
 
 void QXlibWindow::raise()
index 9b64dc5..eb69369 100644 (file)
@@ -112,7 +112,7 @@ public:
 
     void setVisible(bool visible);
     WId winId() const;
-    void setParent(const QPlatformWindow *window);
+    void setParent(const QPlatformWindow *parent);
     void raise();
     void lower();
     void setWindowTitle(const QString &title);