From c58fefcfff7f3d10b8b8a1a43dc06e1371fef454 Mon Sep 17 00:00:00 2001 From: Ben Anderson Date: Sun, 13 Mar 2005 23:50:12 +0000 Subject: [PATCH] Catch and log X11 protocol errors; they might be useful in debugging. --- stepmania/src/archutils/Unix/X11Helper.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/stepmania/src/archutils/Unix/X11Helper.cpp b/stepmania/src/archutils/Unix/X11Helper.cpp index 49c69c89cc..01316844f1 100644 --- a/stepmania/src/archutils/Unix/X11Helper.cpp +++ b/stepmania/src/archutils/Unix/X11Helper.cpp @@ -5,6 +5,7 @@ #include // Display, Window +#include "RageLog.h" // LOG #include "RageDisplay.h" // RageDisplay vector pMasks; // Currently open masks @@ -14,12 +15,24 @@ Window pWin; // Current window unsigned short int pCt = 0; // Number of subsystems // using the X connection +int protoErrorCallback(Display *d, XErrorEvent *err) +{ + char errText[32]; + XGetErrorText(d, err->error_code, errText, 32); + LOG->Warn("X11 Protocol error %s (%d) has occurred, caused by request %d,%d, resource ID %d", + errText, err->error_code, err->request_code, err->minor_code, err->resourceid); + + return 0; // Xlib ignores our return value +} + bool X11Helper::Go() { if(pCt == 0) { pDpy = XOpenDisplay(0); if(pDpy == NULL) { return false; } + + XSetErrorHandler(&protoErrorCallback); } pCt++;