mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-03 10:08:16 +02:00
[cairo-scaled-font] Fix assertion failure
Revert 127c4b8e64
We assume that all scaled fonts with ref count 0 are in holdover cache.
That commit was breaking this assumption.
This commit is contained in:
parent
8c4f4a758b
commit
e8dd97fde8
1 changed files with 7 additions and 8 deletions
|
|
@ -932,6 +932,7 @@ void
|
|||
cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
cairo_scaled_font_t *lru = NULL;
|
||||
cairo_scaled_font_map_t *font_map;
|
||||
|
||||
if (scaled_font == NULL ||
|
||||
CAIRO_REFERENCE_COUNT_IS_INVALID (&scaled_font->ref_count))
|
||||
|
|
@ -939,16 +940,13 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font)
|
|||
|
||||
assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&scaled_font->ref_count));
|
||||
|
||||
font_map = _cairo_scaled_font_map_lock ();
|
||||
assert (font_map != NULL);
|
||||
|
||||
if (_cairo_reference_count_dec_and_test (&scaled_font->ref_count)) {
|
||||
cairo_scaled_font_map_t *font_map;
|
||||
|
||||
/* don't use _cairo_scaled_font_map_lock() to not create it if it's
|
||||
* NULL. if font_map is NULL, it means we are in the process of
|
||||
* destructing it. don't err and continue */
|
||||
CAIRO_MUTEX_LOCK (_cairo_scaled_font_map_mutex);
|
||||
font_map = cairo_scaled_font_map;
|
||||
|
||||
if (!scaled_font->placeholder && font_map && scaled_font->hash_entry.hash != ZOMBIE) {
|
||||
if (!scaled_font->placeholder && scaled_font->hash_entry.hash != ZOMBIE) {
|
||||
/* Rather than immediately destroying this object, we put it into
|
||||
* the font_map->holdovers array in case it will get used again
|
||||
* soon (and is why we must hold the lock over the atomic op on
|
||||
|
|
@ -974,9 +972,10 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font)
|
|||
} else
|
||||
lru = scaled_font;
|
||||
|
||||
CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
|
||||
}
|
||||
|
||||
CAIRO_MUTEX_UNLOCK (_cairo_scaled_font_map_mutex);
|
||||
|
||||
/* If we pulled an item from the holdovers array, (while the font
|
||||
* map lock was held, of course), then there is no way that anyone
|
||||
* else could have acquired a reference to it. So we can now
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue