diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2013-03-08 14:00:27 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-12 09:16:42 +0100 |
commit | 381566445e89c4d945ca40d1fbc12c728e0186b5 (patch) | |
tree | c661cb088525f725dfbdcbfc7962b3f264d82169 /src/plugins/platformthemes | |
parent | 6b821a3dc80b7203a8c9def42294924e5d718068 (diff) |
Reset the X error handler after initializing GTK
It turns out that we were setting the error handler to a dummy one in
qxcbconnection.cpp, but GTK then overrides it to an handler that calls
exit(1) on errors. This causes problems as we are relying on the
glXCreateContextAttribsARB call to fail when creating an OpenGL context,
so we need to reset the handler after GTK initialization.
Change-Id: I9bc3eb2480abfd3740884cb0000b9180d2cf37a5
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/plugins/platformthemes')
-rw-r--r-- | src/plugins/platformthemes/gtk2/qgtk2theme.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/plugins/platformthemes/gtk2/qgtk2theme.cpp b/src/plugins/platformthemes/gtk2/qgtk2theme.cpp index b26ab94b83..f069d9f97c 100644 --- a/src/plugins/platformthemes/gtk2/qgtk2theme.cpp +++ b/src/plugins/platformthemes/gtk2/qgtk2theme.cpp @@ -46,6 +46,8 @@ #undef signals #include <gtk/gtk.h> +#include <X11/Xlib.h> + QT_BEGIN_NAMESPACE const char *QGtk2Theme::name = "gtk2"; @@ -62,7 +64,13 @@ static QString gtkSetting(const gchar *propertyName) QGtk2Theme::QGtk2Theme() { + // 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(NULL); + gtk_init(0, 0); + + XSetErrorHandler(oldErrorHandler); } QVariant QGtk2Theme::themeHint(QPlatformTheme::ThemeHint hint) const |