diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index 51e19175d6f..8551966678a 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -11,7 +11,9 @@ #undef signals #include +#if QT_CONFIG(xcb_xlib) #include +#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. diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.h b/src/plugins/platformthemes/gtk3/qgtk3theme.h index 0f274234d51..8c7a1da7cc1 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.h +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.h @@ -4,6 +4,7 @@ #ifndef QGTK3THEME_H #define QGTK3THEME_H +#include #include QT_BEGIN_NAMESPACE