From 381566445e89c4d945ca40d1fbc12c728e0186b5 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 8 Mar 2013 14:00:27 +0100 Subject: Reset the X error handler after initializing GTK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Samuel Rødal --- src/plugins/platformthemes/gtk2/qgtk2theme.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/plugins/platformthemes') 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 +#include + 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 -- cgit v1.2.3