diff options
author | Bradley Smith <bradley@baysmith.com> | 2011-12-12 21:47:03 -0800 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-13 11:11:58 +0100 |
commit | 0553ab912746ece4a309d9b5b5cf1fd54630ffc2 (patch) | |
tree | 6af70f2d7d27a4d0f7e491c058894af82813d29d /src | |
parent | abb1c066e5203566c5987d6ba0746c2de1e66eb7 (diff) |
Fix QPA xlib plugin handling of setParent(0).
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/xlib/qxlibwindow.cpp | 5 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibwindow.h | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index c14fadaaaa..70eb061c13 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -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() diff --git a/src/plugins/platforms/xlib/qxlibwindow.h b/src/plugins/platforms/xlib/qxlibwindow.h index 9b64dc5624..eb69369150 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.h +++ b/src/plugins/platforms/xlib/qxlibwindow.h @@ -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); |