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>
bb10
Bradley Smith 2011-12-12 21:47:03 -08:00 committed by Qt by Nokia
parent abb1c066e5
commit 0553ab9127
2 changed files with 4 additions and 3 deletions

View 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()

View 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);