diff --git a/objects/drawin.c b/objects/drawin.c index a0083396..3997ae48 100644 --- a/objects/drawin.c +++ b/objects/drawin.c @@ -61,6 +61,14 @@ drawin_systray_kickout(drawin_t *w) static void drawin_wipe_resources(drawin_t *w) { + if(w->surface) + { + /* Make sure that cairo knows that this surface can't be unused anymore. + * This is needed since lua could still have a reference to it. */ + cairo_surface_finish(w->surface); + cairo_surface_destroy(w->surface); + w->surface = NULL; + } if(w->window) { /* Activate BMA */ @@ -77,11 +85,6 @@ drawin_wipe_resources(drawin_t *w) xcb_free_pixmap(globalconf.connection, w->pixmap); w->pixmap = XCB_NONE; } - if(w->surface) - { - cairo_surface_destroy(w->surface); - w->surface = NULL; - } } static void