[cairo-commit] 2 commits - src/cairo-surface.c

Andrea Canciani ranma42 at kemper.freedesktop.org
Wed Dec 29 10:07:30 PST 2010


 src/cairo-surface.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 7f68461e0b64fefc002920cc23f5617a9084f1cb
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Dec 26 11:04:30 2010 +0100

    Detach snapshots after flushing in cairo_surface_finish()
    
    Flushing a surface can attach snapshots to it, thus we have to detach
    the snapshots after the flush, to make sure they aren't leaked.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index bc80d08..b5ed334 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -715,12 +715,13 @@ cairo_surface_finish (cairo_surface_t *surface)
     if (surface->finished)
 	return;
 
+    cairo_surface_flush (surface);
+
     /* update the snapshots *before* we declare the surface as finished */
     _cairo_surface_detach_snapshots (surface);
     if (surface->snapshot_of != NULL)
 	_cairo_surface_detach_snapshot (surface);
 
-    cairo_surface_flush (surface);
     surface->finished = TRUE;
 
     /* call finish even if in error mode */
commit 59ac884c607c024d0608cf7dec52509d9e9e328e
Author: Uli Schlachter <psychon at znc.in>
Date:   Sat Dec 25 23:39:21 2010 +0100

    Verify that surfaces leak no snapshots
    
    Finished surfaces should own no snapshots, because finished surfaces
    can't be used as sources, thus their snapshots would never be used.
    
    When free'ing the surface in cairo_surface_destroy(), it should have
    no snapshots, or they will be leaked.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 01ea27a..bc80d08 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -654,6 +654,9 @@ cairo_surface_destroy (cairo_surface_t *surface)
     if (surface->owns_device)
         cairo_device_destroy (surface->device);
 
+    assert (surface->snapshot_of == NULL);
+    assert (!_cairo_surface_has_snapshots (surface));
+
     free (surface);
 }
 slim_hidden_def(cairo_surface_destroy);
@@ -726,6 +729,9 @@ cairo_surface_finish (cairo_surface_t *surface)
 	if (unlikely (status))
 	    status = _cairo_surface_set_error (surface, status);
     }
+
+    assert (surface->snapshot_of == NULL);
+    assert (!_cairo_surface_has_snapshots (surface));
 }
 slim_hidden_def (cairo_surface_finish);
 


More information about the cairo-commit mailing list