From f57dbb6a78de7270f65f8e869ca36ab4a15186d9 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 19 Dec 2010 14:29:52 +0100 Subject: [PATCH] Remove a possibility for lua to cause X11 errors The lua code could keep a reference to out cairo surface for a drawin after it was destroyed. So make sure the surface is finished before the associated drawable is destroyed. Signed-off-by: Uli Schlachter --- objects/drawin.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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