summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>2013-01-31 15:55:57 +0100
committerPeter Hutterer <peter.hutterer@who-t.net>2013-02-05 11:55:11 +1000
commit77d3c8afb6e9224469d7dffcebf1cb23b36ecc0e (patch)
tree507dc737ec88c839909146b126f9431265e160aa
parente1168f49fb7d559463967a692597214f9ce46e9c (diff)
Fix registering error handlers
It looks like xorg-gtest and libX11 have a different idea of where the error handler pointer is supposed to point at. Check for the default handler returned from XSet*ErrorHandler by setting a NULL error handler first. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/xserver.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/xserver.cpp b/src/xserver.cpp
index def6a89..a36ca7e 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -436,19 +436,27 @@ static int _x_io_error_handler(Display *dpy)
void xorg::testing::XServer::RegisterXIOErrorHandler()
{
- XIOErrorHandler old_handler;
- old_handler = XSetIOErrorHandler(_x_io_error_handler);
+ XIOErrorHandler old_handler, def_handler;
- if (old_handler != _XDefaultIOError)
+ old_handler = XSetIOErrorHandler(NULL);
+ def_handler = XSetIOErrorHandler(_x_io_error_handler);
+
+ if (old_handler != def_handler &&
+ old_handler != _XDefaultIOError &&
+ old_handler != _x_io_error_handler)
XSetIOErrorHandler(old_handler);
}
void xorg::testing::XServer::RegisterXErrorHandler()
{
- XErrorHandler old_handler;
- old_handler = XSetErrorHandler(_x_error_handler);
+ XErrorHandler old_handler, def_handler;
+
+ old_handler = XSetErrorHandler(NULL);
+ def_handler = XSetErrorHandler(_x_error_handler);
- if (old_handler != _XDefaultError)
+ if (old_handler != def_handler &&
+ old_handler != _XDefaultError &&
+ old_handler != _x_error_handler)
XSetErrorHandler(old_handler);
}