summaryrefslogtreecommitdiff
path: root/src/cairo-pattern.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-06-19 11:42:43 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-06-19 12:29:49 +0100
commit565644e616ea64f97769d8939beb155f4031da2f (patch)
treee3339a332afedb53dca91e8599bf83fd27045f58 /src/cairo-pattern.c
parent47d8739ea198510919b2611c34a44aa3c63f3f59 (diff)
[cairo-pattern] Band-aid for the solid surface cache.
Behdad noticed that the mixing of dissimilar surfaces within the cache was fubar (http://lists.cairographics.org/archives/cairo/2008-June/014348.html). This corrects the dereferencing of the evicted surface, but leaves open the question of the future of the cache.
Diffstat (limited to 'src/cairo-pattern.c')
-rw-r--r--src/cairo-pattern.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 89e92ca7..b9f068a6 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1453,9 +1453,10 @@ _cairo_pattern_acquire_surface_for_solid (cairo_solid_pattern_t *pattern,
&pattern->base);
if (status)
goto UNLOCK;
+
+ cairo_surface_reference (surface);
} else {
/* Unable to reuse, evict */
- cairo_surface_destroy (surface);
surface = NULL;
}
}
@@ -1485,6 +1486,7 @@ _cairo_pattern_acquire_surface_for_solid (cairo_solid_pattern_t *pattern,
i = solid_surface_cache.size++;
solid_surface_cache.cache[i].color = pattern->color;
+ cairo_surface_destroy (solid_surface_cache.cache[i].surface);
solid_surface_cache.cache[i].surface = surface;
DONE:
@@ -1513,8 +1515,11 @@ _cairo_pattern_reset_solid_surface_cache (void)
/* remove surfaces starting from the end so that solid_surface_cache.cache
* is always in a consistent state when we release the mutex. */
while (solid_surface_cache.size) {
- cairo_surface_t *surface = solid_surface_cache.cache[solid_surface_cache.size-1].surface;
+ cairo_surface_t *surface;
+
solid_surface_cache.size--;
+ surface = solid_surface_cache.cache[solid_surface_cache.size].surface;
+ solid_surface_cache.cache[solid_surface_cache.size].surface = NULL;
/* release the lock to avoid the possibility of a recursive
* deadlock when the scaled font destroy closure gets called */