From bf442ff5de277537dca40ee194bec984eeaa33c4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ingo=20B=C3=BCrk?= Date: Wed, 18 Nov 2015 15:32:45 +0100 Subject: [PATCH] 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 --- libi3/draw_util.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libi3/draw_util.c b/libi3/draw_util.c index f6c53865..e33a9ecb 100644 --- a/libi3/draw_util.c +++ b/libi3/draw_util.c @@ -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 } -- 2.39.5