X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bin%2Foverride.c;h=113a63844597d4f61151616d6e9ab350bdf9972d;hb=209c152e39ae22bf3842ff81f5b829c099d3aae7;hp=c6084d88e4b0644016b84b8ce1a955b4f5bd3f22;hpb=f3bef788226766f2251c5acdaa4667c2728089d3;p=vlc diff --git a/bin/override.c b/bin/override.c index c6084d88e4..113a638445 100644 --- a/bin/override.c +++ b/bin/override.c @@ -192,6 +192,43 @@ int sigaction (int signum, const struct sigaction *act, struct sigaction *old) } +/*** Xlib ****/ +#ifdef HAVE_X11_XLIB_H +# include + +static pthread_mutex_t xlib_lock = PTHREAD_MUTEX_INITIALIZER; + +int (*XSetErrorHandler (int (*handler) (Display *, XErrorEvent *))) + (Display *, XErrorEvent *) +{ + if (override) + { + int (*ret) (Display *, XErrorEvent *); + + pthread_mutex_lock (&xlib_lock); + LOG("Error", "%p", handler); + ret = CALL(XSetErrorHandler, handler); + pthread_mutex_unlock (&xlib_lock); + return ret; + } + return CALL(XSetErrorHandler, handler); +} + +int (*XSetIOErrorHandler (int (*handler) (Display *))) (Display *) +{ + if (override) + { + int (*ret) (Display *); + + pthread_mutex_lock (&xlib_lock); + LOG("Error", "%p", handler); + ret = CALL(XSetIOErrorHandler, handler); + pthread_mutex_unlock (&xlib_lock); + return ret; + } + return CALL(XSetIOErrorHandler, handler); +} +#endif #else static void vlc_enable_override (void) {