Skip to content

Commit

Permalink
QGtk3Theme: Respect xcb_xlib config option
Browse files Browse the repository at this point in the history
Pick-to: 6.4 6.3 6.2
Change-Id: I4b01a694e8a13a6f009296d8ccfa8f8eb21043e4
Reviewed-by: Liang Qi <[email protected]>
  • Loading branch information
ilya-fedin committed Jul 6, 2022
1 parent 3d45f23 commit dbe858b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/plugins/platformthemes/gtk3/qgtk3theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#undef signals
#include <gtk/gtk.h>

#if QT_CONFIG(xcb_xlib)
#include <X11/Xlib.h>
#endif

QT_BEGIN_NAMESPACE

Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/plugins/platformthemes/gtk3/qgtk3theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef QGTK3THEME_H
#define QGTK3THEME_H

#include <private/qtguiglobal_p.h>
#include <private/qgenericunixthemes_p.h>

QT_BEGIN_NAMESPACE
Expand Down

0 comments on commit dbe858b

Please sign in to comment.