loader/dri3: Destroy Present event context when destroying drawable v2
authorMichel Dänzer <michel.daenzer@amd.com>
Thu, 28 Jul 2016 08:44:49 +0000 (17:44 +0900)
committerMichel Dänzer <michel@daenzer.net>
Thu, 4 Aug 2016 06:45:43 +0000 (15:45 +0900)
Without this, the X server may accumulate stale Present event contexts
if a client ends up creating and destroying DRI drawables for the same
window.

v2: Based on Chris Wilson's review:
* Use xcb_present_select_input_checked so that protocol errors
  generated by old X servers can be handled gracefully
* Use xcb_discard_reply() instead of free(xcb_request_check())

src/loader/loader_dri3_helper.c

index 67d0c2c2f3a1521112cb160067805ae331a5dd15..e9fb97bfaf7b13cac98635190a5a422c1e31cfa9 100644 (file)
@@ -118,8 +118,14 @@ loader_dri3_drawable_fini(struct loader_dri3_drawable *draw)
          dri3_free_render_buffer(draw, draw->buffers[i]);
    }
 
-   if (draw->special_event)
+   if (draw->special_event) {
+      xcb_void_cookie_t cookie =
+         xcb_present_select_input_checked(draw->conn, draw->eid, draw->drawable,
+                                          XCB_PRESENT_EVENT_MASK_NO_EVENT);
+
+      xcb_discard_reply(draw->conn, cookie.sequence);
       xcb_unregister_for_special_event(draw->conn, draw->special_event);
+   }
 }
 
 int