diff -u ChangeLog ChangeLog --- ChangeLog 13 Sep 2005 16:27:50 -0000 +++ ChangeLog 13 Sep 2005 17:07:25 -0000 @@ -1,5 +1,10 @@ 2005-09-13 Carl Worth + * src/cairo-scaled-font.c: (_cairo_scaled_glyph_lookup): Add + missing locking around the call into the thread-shared cache here. + +2005-09-13 Carl Worth + * src/cairo-scaled-font.c: (cairo_scaled_font_reference), (cairo_scaled_font_destroy): Expand locking to encapsulate any modification to the reference count of a scaled font, rather than diff -u src/cairo-scaled-font.c src/cairo-scaled-font.c --- src/cairo-scaled-font.c 13 Sep 2005 16:25:03 -0000 +++ src/cairo-scaled-font.c 13 Sep 2005 16:31:27 -0000 @@ -1111,7 +1111,7 @@ cairo_scaled_glyph_info_t info, cairo_scaled_glyph_t **scaled_glyph_ret) { - cairo_status_t status; + cairo_status_t status = CAIRO_STATUS_SUCCESS; cairo_cache_entry_t key; cairo_scaled_glyph_t *scaled_glyph; cairo_scaled_glyph_info_t need_info; @@ -1119,6 +1119,8 @@ if (scaled_font->status) return scaled_font->status; + CAIRO_MUTEX_LOCK (cairo_scaled_font_map_mutex); + key.hash = index; /* * Check cache for glyph @@ -1133,8 +1135,7 @@ scaled_glyph = malloc (sizeof (cairo_scaled_glyph_t)); if (scaled_glyph == NULL) { status = CAIRO_STATUS_NO_MEMORY; - _cairo_scaled_font_set_error (scaled_font, status); - return status; + goto CLEANUP; } _cairo_scaled_glyph_set_index(scaled_glyph, index); @@ -1147,18 +1148,13 @@ /* ask backend to initialize metrics and shape fields */ status = (*scaled_font->backend-> scaled_glyph_init) (scaled_font, scaled_glyph, info); - if (status) { - _cairo_scaled_glyph_destroy (scaled_glyph); - _cairo_scaled_font_set_error (scaled_font, status); - return status; - } + if (status) + goto CLEANUP; + status = _cairo_cache_insert (scaled_font->glyphs, &scaled_glyph->cache_entry); - if (status) { - _cairo_scaled_glyph_destroy (scaled_glyph); - _cairo_scaled_font_set_error (scaled_font, status); - return status; - } + if (status) + goto CLEANUP; } /* * Check and see if the glyph, as provided, @@ -1179,6 +1175,18 @@ if (status) - return status; + goto CLEANUP; + } + + CLEANUP: + if (status) { + _cairo_scaled_font_set_error (scaled_font, status); + if (scaled_glyph) + _cairo_scaled_glyph_destroy (scaled_glyph); + *scaled_glyph_ret = NULL; + } else { + *scaled_glyph_ret = scaled_glyph; } - *scaled_glyph_ret = scaled_glyph; - return CAIRO_STATUS_SUCCESS; + + CAIRO_MUTEX_UNLOCK (cairo_scaled_font_map_mutex); + + return status; }