From 0553ab912746ece4a309d9b5b5cf1fd54630ffc2 Mon Sep 17 00:00:00 2001 From: Bradley Smith Date: Mon, 12 Dec 2011 21:47:03 -0800 Subject: Fix QPA xlib plugin handling of setParent(0). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/plugins/platforms/xlib/qxlibwindow.cpp | 5 +++-- 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); -- cgit v1.2.3