From 3f473f4025a58deba1701a51d3e4739c6526ee3b Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 2 Jul 2022 13:53:28 +0400 Subject: [PATCH] QGtk3Theme: Respect xcb_xlib config option Change-Id: I4b01a694e8a13a6f009296d8ccfa8f8eb21043e4 Reviewed-by: Liang Qi (cherry picked from commit dbe858bf80f554c4d916ee230fc9dcde01699bd7) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 6 ++++++ src/plugins/platformthemes/gtk3/qgtk3theme.h | 1 + 2 files changed, 7 insertions(+) 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