From f864e2d70f53a1feeee5e32bf9724b1e544025a6 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 8 Sep 2012 16:39:05 +0100 Subject: [PATCH] xlib/shm: Explicitly release shm surface if we do not own the pixmap In this case we want to prevent the short-circuiting of the flush of the ShmPixmap that is ordinarily performed during finish(). Signed-off-by: Chris Wilson --- src/cairo-xlib-surface.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index a35ea43b2..ab21912d1 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -377,11 +377,18 @@ _cairo_xlib_surface_finish (void *abstract_surface) XRenderFreePicture (display->display, surface->embedded_source.picture); if (surface->picture) XRenderFreePicture (display->display, surface->picture); + + if (surface->shm) { + /* Force the flush for an external surface */ + if (!surface->owns_pixmap) + cairo_surface_flush (surface->shm); + cairo_surface_finish (surface->shm); + cairo_surface_destroy (surface->shm); + } + if (surface->owns_pixmap) XFreePixmap (display->display, surface->drawable); - cairo_surface_destroy (surface->shm); - cairo_device_release (&display->base); return status;