summaryrefslogtreecommitdiff
path: root/src/cairo-scaled-font.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-05-04 18:25:23 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-05-04 18:26:06 +0100
commit19ac81f50ba353400934bf112523b4257ad9de2f (patch)
tree275c387031e424bc51dee51ac37ab0d31d151afc /src/cairo-scaled-font.c
parent6f2d4f5b2aba9344fee9375614dfd0c6236bfd7c (diff)
scaled-font: Remove MRU cache upon detection of error.
Diffstat (limited to 'src/cairo-scaled-font.c')
-rw-r--r--src/cairo-scaled-font.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 5ed69b16..ce92354d 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -895,7 +895,7 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
cairo_status_t status;
cairo_scaled_font_map_t *font_map;
cairo_font_face_t *original_font_face = font_face;
- cairo_scaled_font_t key, *old = NULL, *scaled_font = NULL;
+ cairo_scaled_font_t key, *old = NULL, *scaled_font = NULL, *dead = NULL;
double det;
status = font_face->status;
@@ -926,6 +926,7 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
_cairo_scaled_font_matches (scaled_font,
font_face, font_matrix, ctm, options))
{
+ assert (scaled_font->hash_entry.hash != ZOMBIE);
assert (! scaled_font->placeholder);
if (likely (scaled_font->status == CAIRO_STATUS_SUCCESS)) {
@@ -942,6 +943,8 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
_cairo_hash_table_remove (font_map->hash_table,
&scaled_font->hash_entry);
scaled_font->hash_entry.hash = ZOMBIE;
+ dead = scaled_font;
+ font_map->mru_scaled_font = NULL;
if (font_face->backend->get_implementation != NULL) {
font_face = font_face->backend->get_implementation (font_face,
@@ -950,6 +953,7 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
options);
if (unlikely (font_face->status)) {
_cairo_scaled_font_map_unlock ();
+ cairo_scaled_font_destroy (scaled_font);
return _cairo_scaled_font_create_in_error (font_face->status);
}
}
@@ -1049,6 +1053,9 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
if (font_face != original_font_face)
cairo_font_face_destroy (font_face);
+ if (dead != NULL)
+ cairo_scaled_font_destroy (dead);
+
status = _cairo_font_face_set_error (font_face, status);
return _cairo_scaled_font_create_in_error (status);
}
@@ -1058,6 +1065,9 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
if (font_face != original_font_face)
cairo_font_face_destroy (font_face);
+ if (dead != NULL)
+ cairo_scaled_font_destroy (dead);
+
return scaled_font;
}
@@ -1084,6 +1094,9 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
if (font_face != original_font_face)
cairo_font_face_destroy (font_face);
+ if (dead != NULL)
+ cairo_scaled_font_destroy (dead);
+
if (unlikely (status)) {
/* We can't call _cairo_scaled_font_destroy here since it expects
* that the font has already been successfully inserted into the