5

Here's an example I saw for some GLX code:

display = XOpenDisplay(0);
// ...
xcb_connection_t *connection = XGetXCBConnection(display);
// ...
XCloseDisplay(display);

I noticed that there was no xcb_disconnect in there. Is this correct? Also, is connection still valid after the display is closed?

Charles
  • 50,943
  • 13
  • 104
  • 142
Pubby
  • 51,882
  • 13
  • 139
  • 180

1 Answers1

7

XCloseDisplay seems to undo the creation of the display (hence destroying it), and since the XCB connection object is derived from the display, it would seem reasonable that the connection becomes invalidated once the display is closed.

gvl
  • 903
  • 7
  • 16
  • Yeah, that's what I was thinking. It would be great if you had a citation to back it up though. – Pubby Jun 16 '12 at 00:49
  • I found it: `XCloseDisplay` explicitly calls `xcb_disconnect`: http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/ClDisplay.c at line 71 – gvl Jun 16 '12 at 03:30
  • 1
    And `dpy->xcb->connection` is exactly what `XGetXCBConnection` returns: http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/x11_xcb.c – gvl Jun 16 '12 at 03:32
  • I am getting a segfault when closing the connection after XGetXCBConnection() on the same display O_o – Alex Barker Jul 30 '17 at 18:43