Re: [PATCH 2/2] xlib: Call XSync() before ignoring errors

Uli Schlachter <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On 07.03.2017 11:31, Chris Wilson wrote:
> On Tue, Mar 07, 2017 at 11:21:31AM +0100, Uli Schlachter wrote:
>> The code here wants to ignore errors for a specific request. To do so,
>> it sets a no-op error handler. However, it could happen that some
>> previous request caused an error and this error will also be ignored by
>> the no-op error handler.
>>
>> To avoid this, call XSync() before setting the error handler. This makes
>> sure that all pending errors are handled.
>>
>> Signed-off-by: Uli Schlachter <[email protected]>
>> ---
>>  src/cairo-xlib-surface.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
>> index 84e7c8e49..908d76daf 100644
>> --- a/src/cairo-xlib-surface.c
>> +++ b/src/cairo-xlib-surface.c
>> @@ -787,6 +787,7 @@ _get_image_surface (cairo_xlib_surface_t    *surface,
>>  
>>  	    _cairo_xlib_shm_surface_get_ximage (&image->base, &shm_image);
>>  
>> +	    XSync (display->display, False);
>>  	    old_handler = XSetErrorHandler (_noop_error_handler);
> 
> I was thinking if only we could check for an error from this request,
> and remembered this is not xcb.
> Reviewed-by: Chris Wilson <[email protected]>

Even better: XSetErrorHandler() has no Display* argument. This sets a
global variable! This code is not even thread-safe and it cannot be.
Hopefully, no one uses multiple Displays in a single program...

Uli
-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.