QGtk3Dialog: don't crash on Wayland

Check if it's an X11 window before calling XSetTransientForHint().
No transient parent will be set for GTK+ dialogs on Wayland. That
has to be implemented separately.

Task-number: QTBUG-55583
Change-Id: Iabc2a72681c8157bb2f2fe500892853aa397106b
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
J-P Nurmi 2016-12-06 16:30:31 +01:00 committed by Jani Heikkinen
parent 181860e1af
commit 84ea00d470

View File

@ -135,10 +135,12 @@ bool QGtk3Dialog::show(Qt::WindowFlags flags, Qt::WindowModality modality, QWind
GdkWindow *gdkWindow = gtk_widget_get_window(gtkWidget); GdkWindow *gdkWindow = gtk_widget_get_window(gtkWidget);
if (parent) { if (parent) {
GdkDisplay *gdkDisplay = gdk_window_get_display(gdkWindow); if (GDK_IS_X11_WINDOW(gdkWindow)) {
XSetTransientForHint(gdk_x11_display_get_xdisplay(gdkDisplay), GdkDisplay *gdkDisplay = gdk_window_get_display(gdkWindow);
gdk_x11_window_get_xid(gdkWindow), XSetTransientForHint(gdk_x11_display_get_xdisplay(gdkDisplay),
parent->winId()); gdk_x11_window_get_xid(gdkWindow),
parent->winId());
}
} }
if (modality != Qt::NonModal) { if (modality != Qt::NonModal) {