1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
From 70a85d441d973883af4afb57599bc570eeea4c83 Mon Sep 17 00:00:00 2001
From: Kristian Rietveld <kris@loopnest.org>
Date: Tue, 5 Jun 2012 22:34:59 +0200
Subject: [PATCH] coretext: don't insert item in the hash if it originated
from the hash
Oversight in my fallback fix, this resulted in things being wrongly
destroyed due to unrefs. Oops.
---
pango/pangocoretext-fontmap.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/pango/pangocoretext-fontmap.c b/pango/pangocoretext-fontmap.c
index a856593..034d050 100644
--- a/pango/pangocoretext-fontmap.c
+++ b/pango/pangocoretext-fontmap.c
@@ -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
@@ -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))
@@ -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))
@@ -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 */
--
1.7.8.6
|