Make freeing surfaces idempotent

If a window with border is set to "border none" and then closed, we would
call cairo_destroy / cairo_surface_destroy twice, causing an assertion
failure in cairo as the objects already had zero references the second
time. We fix this by explicitly setting these objects to NULL.

relates to #1278
This commit is contained in:
Ingo Bürk 2015-11-18 15:32:45 +01:00
parent 780cb8d15d
commit bf442ff5de
1 changed files with 6 additions and 0 deletions

View File

@ -66,6 +66,12 @@ void draw_util_surface_free(xcb_connection_t *conn, surface_t *surface) {
#ifdef CAIRO_SUPPORT #ifdef CAIRO_SUPPORT
cairo_surface_destroy(surface->surface); cairo_surface_destroy(surface->surface);
cairo_destroy(surface->cr); cairo_destroy(surface->cr);
/* We need to explicitly set these to NULL to avoid assertion errors in
* cairo when calling this multiple times. This can happen, for example,
* when setting the border of a window to none and then closing it. */
surface->surface = NULL;
surface->cr = NULL;
#endif #endif
} }