]> git.sur5r.net Git - i3/i3/blobdiff - libi3/draw_util.c
Make freeing surfaces idempotent
[i3/i3] / libi3 / draw_util.c
index f6c53865b4937cd0feb60cfa0f2249d37d2b7a84..e33a9ecbd4a05a8750abea3536b7bdc68013e2ca 100644 (file)
@@ -66,6 +66,12 @@ void draw_util_surface_free(xcb_connection_t *conn, surface_t *surface) {
 #ifdef CAIRO_SUPPORT
     cairo_surface_destroy(surface->surface);
     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
 }