[Xcb] XCB error handling; my penultimate proposal

Jamey Sharp jamey at minilop.net
Mon Dec 19 11:33:20 PST 2005


On Sun, Dec 18, 2005 at 09:12:10PM -0800, Barton C Massey wrote:
> Comments?  Especially from someone other than the three of us?

Sorry, I can't help there. ;-)

> If we were to make the current API do (1), then applications that
> didn't check *Reply() for null on *every* request would lose, ...

They already lose: if you derefence the null reply pointer you get back
under error conditions, your app is going to segfault.

In message <1134963912.8789.4.camel at evo.keithp.com> Keith Packard wrote:
> While the uniform behaviour of always processing errors through the
> normal event loop is appealingly symmetrical, I'm afraid I haven't seen
> any substantive use cases where this is better than returning errors
> where the reply would have been, and there are plenty of examples where
> returning the error precisely where the reply would have been makes
> things far easier.
> 
> We can obviously add Bart's APIs in a later release; I only suggest that
> we hold off until we find a compelling reason to extend the library in
> this fashion.

I like Bart's API (aside from the changes I suggested in my last mail)
at least for implementing Xlib/XCB, which probably ought to capture the
errors from all requests made through Xlib even if XCB owns the event
queue, and even for void requests. That way an Xlib-based library (like
Gtk+, for instance) can register an X error handler temporarily and have
it actually work, even when the rest of the app is ported to XCB.

Speaking of Gtk+, here's a use case for the ability to catch X errors
from void requests, which Bart's API does nicely. From gdkevents-x11.c,
in fetch_net_wm_check_window:

  gdk_error_trap_push ();
  XSelectInput (screen_x11->xdisplay, *xwindow, StructureNotifyMask);
  gdk_display_sync (display);
  if (gdk_error_trap_pop () == Success)
  ...

And another, from gdkimage-x11.c in _gdk_image_new_for_depth:

  gdk_error_trap_push ();

  XShmAttach (screen_x11->xdisplay, x_shm_info);
  XSync (screen_x11->xdisplay, False);

  if (gdk_error_trap_pop ())
    {
      /* this is the common failure case so omit warning */
      display_x11->use_xshm = FALSE;
      goto error;
    }

And from gdkmain-x11.c in _gdk_send_xevent:

  gdk_error_trap_push ();
  result = XSendEvent (GDK_DISPLAY_XDISPLAY (display), window,
                       propagate, event_mask, event_send);
  XSync (GDK_DISPLAY_XDISPLAY (display), False);
  return result && gdk_error_trap_pop() == Success;

(Which looks buggy, since it might not pop the error trap stack...)

I suspect if we really looked we'd find more.

--Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20051219/0939e886/attachment-0001.pgp


More information about the Xcb mailing list