QGtk3Theme: Respect xcb_xlib config option

Pick-to: 6.4 6.3 6.2
Change-Id: I4b01a694e8a13a6f009296d8ccfa8f8eb21043e4
Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
Ilya Fedin 2022-07-02 13:53:28 +04:00
parent 3d45f23b02
commit dbe858bf80
2 changed files with 7 additions and 0 deletions

View File

@ -11,7 +11,9 @@
#undef signals
#include <gtk/gtk.h>
#if QT_CONFIG(xcb_xlib)
#include <X11/Xlib.h>
#endif
QT_BEGIN_NAMESPACE
@ -60,13 +62,17 @@ QGtk3Theme::QGtk3Theme()
else if (QGuiApplication::platformName() == "xcb"_L1)
gdk_set_allowed_backends("x11,wayland");
#if QT_CONFIG(xcb_xlib)
// gtk_init will reset the Xlib error handler, and that causes
// Qt applications to quit on X errors. Therefore, we need to manually restore it.
int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(nullptr);
#endif
gtk_init(nullptr, nullptr);
#if QT_CONFIG(xcb_xlib)
XSetErrorHandler(oldErrorHandler);
#endif
/* Initialize some types here so that Gtk+ does not crash when reading
* the treemodel for GtkFontChooser.

View File

@ -4,6 +4,7 @@
#ifndef QGTK3THEME_H
#define QGTK3THEME_H
#include <private/qtguiglobal_p.h>
#include <private/qgenericunixthemes_p.h>
QT_BEGIN_NAMESPACE