[cairo-commit] src/cairo-xcb-screen.c

Uli Schlachter psychon at kemper.freedesktop.org
Thu Feb 10 12:41:30 PST 2011


 src/cairo-xcb-screen.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 050a877a9e6a0066200783f1e200eaaf6792e5de
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Feb 10 17:33:52 2011 +0100

    xcb: Fix a crash when finishing a device
    
    The xcb backend uses caches for linear, radial and surface patterns so that it
    doesn't have to create a new cairo_xcb_picture_t on every use. Whenever any
    picture is finished, the surface pattern cache is checked on whether it still
    contains that picture.
    
    This means that we cannot destroy the surface_pattern_cache until after the
    linear and radial_pattern_cache are destroyed or else we'll be querying the
    surface pattern cache after it was finished.
    
    This wasn't noticed before because _cairo_xcb_picture_finish couldn't acquire
    the cairo_xcb_connection_t and thus failed earlier. The previous commit changed
    this and now lots of tests in the test suite trigger the crash.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-screen.c b/src/cairo-xcb-screen.c
index 5e94d49..839e38e 100644
--- a/src/cairo-xcb-screen.c
+++ b/src/cairo-xcb-screen.c
@@ -68,9 +68,12 @@ _cairo_xcb_screen_finish (cairo_xcb_screen_t *screen)
     for (i = 0; i < ARRAY_LENGTH (screen->stock_colors); i++)
 	cairo_surface_destroy (screen->stock_colors[i]);
 
-    _cairo_cache_fini (&screen->surface_pattern_cache);
     _cairo_cache_fini (&screen->linear_pattern_cache);
     _cairo_cache_fini (&screen->radial_pattern_cache);
+    /* Do this one last, because the above two will cause picture_t
+     * to be finished. This results in a call to ..._remove_surface_picture
+     * which uses the surface pattern cache. */
+    _cairo_cache_fini (&screen->surface_pattern_cache);
     _cairo_freelist_fini (&screen->pattern_cache_entry_freelist);
 
     cairo_device_finish (screen->device);


More information about the cairo-commit mailing list