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>
bb10
Giuseppe D'Angelo 2013-03-08 14:00:27 +01:00 committed by The Qt Project
parent 6b821a3dc8
commit 381566445e
1 changed files with 8 additions and 0 deletions

View File

@ -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