Re: [PATCH xlib] Add support for a display-specific error handler

2015-11-19 Thread Uli Schlachter
Am 16.11.2015 um 21:57 schrieb Jasper St. Pierre: > Now do this: > > static void Foo() > { > Request1(); > Request2(); > } > > static void Bar() > { > Request1(); > Request3(); > } > > static void Thing(int x) > { > SetErrorHandler(); > if (x == 0) > Foo(); >

Re: [PATCH xlib] Add support for a display-specific error handler

2015-11-16 Thread Jasper St. Pierre
Yes. This is the case we're seeing. Looking back on it now, it seems my patch doesn't actually help, because my driver wasn't always using a separate Display connection like I thought it was. TLS doesn't actually help, since the main-loop is always in the same situation. I wonder if this would wor

Re: [PATCH xlib] Add support for a display-specific error handler

2015-11-16 Thread Adam Jackson
On Fri, 2015-11-13 at 15:24 -0800, Jasper St. Pierre wrote: > Writing error-safe code that uses Xlib is too obnoxious, and using XCB > is tedious and not performant, as we can't catch events on a giant > stream -- we have to check every operation manually. > > In my specific case (writing a GL dri

Re: [PATCH xlib] Add support for a display-specific error handler

2015-11-16 Thread Jasper St. Pierre
Now do this: static void Foo() { Request1(); Request2(); } static void Bar() { Request1(); Request3(); } static void Thing(int x) { SetErrorHandler(); if (x == 0) Foo(); else Bar(); UnsetErrorHandlerAndCheck(); } We have a similar codepath in our

Re: [PATCH xlib] Add support for a display-specific error handler

2015-11-16 Thread Uli Schlachter
Am 16.11.2015 um 18:06 schrieb Jasper St. Pierre: [...] > We currently use a behavior like: > > SetErrorHandler(); > Request1(); > Request2(); > Request3(); > if (UnsetErrorHandlerAndCheck()) > goto error; > > UnsetErrorHandlerAndCheck will XSync, and look at any newly

Re: [PATCH xlib] Add support for a display-specific error handler

2015-11-16 Thread Jasper St. Pierre
Yes, because Xlib will pick those events up and call its default handler in its mainloop. As far as I can tell, there's no way to configure that behavior. Using xcb without the Xlib mainloop is not an option, because this is a library embedded in another application and its API takes an Xlib Displa

Re: [PATCH xlib] Add support for a display-specific error handler

2015-11-15 Thread Keith Packard
"Jasper St. Pierre" writes: > Writing error-safe code that uses Xlib is too obnoxious, and using XCB > is tedious and not performant, as we can't catch events on a giant > stream -- we have to check every operation manually. You get errors returned in the event stream; is there something fancier

[PATCH xlib] Add support for a display-specific error handler

2015-11-13 Thread Jasper St. Pierre
Writing error-safe code that uses Xlib is too obnoxious, and using XCB is tedious and not performant, as we can't catch events on a giant stream -- we have to check every operation manually. In my specific case (writing a GL driver), it would be enough to simply have a Display-specific error handl