[PATCH] xorg-gtest: fix registering error handlers

Maarten Lankhorst maarten.lankhorst at canonical.com
Thu Jan 31 06:55:57 PST 2013


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 at canonical.com>
---
Probably some funny interaction with symbol lookup, presumably
_XDefault*Error points to some stub first or something,

I don't really want to know, but it fixes up xorg-gtest 0.7.0
enough to make it run all selftests again on precise.

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);
 }
 



More information about the xorg-devel mailing list