Skip to content

Commit

Permalink
coretext: don't insert item in the hash if it originated from the hash
Browse files Browse the repository at this point in the history
Oversight in my fallback fix, this resulted in things being wrongly
destroyed due to unrefs. Oops.
  • Loading branch information
krietvel committed Jun 5, 2012
1 parent b63a890 commit 70a85d4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions pango/pangocoretext-fontmap.c
Expand Up @@ -1284,13 +1284,11 @@ pango_core_text_font_map_load_fontset (PangoFontMap *fontmap,

if (G_UNLIKELY (!fontset))
{
gboolean insert_in_hash = TRUE;

fontset = pango_core_text_fontset_new (&key, desc);

if (G_LIKELY (fontset))
g_hash_table_insert (ctfontmap->fontset_hash,
pango_core_text_fontset_get_key (fontset),
fontset);
else
if (G_UNLIKELY (!fontset))
{
/* If no font(set) could be loaded, we fallback to "Sans",
* which should always work on Mac. We try to adhere to the
Expand All @@ -1308,7 +1306,9 @@ pango_core_text_font_map_load_fontset (PangoFontMap *fontmap,
language);

fontset = g_hash_table_lookup (ctfontmap->fontset_hash, &key);
if (G_UNLIKELY (!fontset))
if (G_LIKELY (fontset))
insert_in_hash = FALSE;
else
fontset = pango_core_text_fontset_new (&key, tmp_desc);

if (G_UNLIKELY (!fontset))
Expand All @@ -1335,7 +1335,9 @@ pango_core_text_font_map_load_fontset (PangoFontMap *fontmap,
}

fontset = g_hash_table_lookup (ctfontmap->fontset_hash, &key);
if (G_UNLIKELY (!fontset))
if (G_LIKELY (fontset))
insert_in_hash = FALSE;
else
fontset = pango_core_text_fontset_new (&key, tmp_desc);

if (G_UNLIKELY (!fontset))
Expand All @@ -1346,11 +1348,12 @@ pango_core_text_font_map_load_fontset (PangoFontMap *fontmap,
g_error ("Could not load fallback font, bailing out.");
}
}

g_hash_table_insert (ctfontmap->fontset_hash,
pango_core_text_fontset_get_key (fontset),
fontset);
}

if (insert_in_hash)
g_hash_table_insert (ctfontmap->fontset_hash,
pango_core_text_fontset_get_key (fontset),
fontset);
}

/* Cannot use pango_core_text_fontset_key_free() here */
Expand Down

0 comments on commit 70a85d4

Please sign in to comment.