summaryrefslogtreecommitdiff
path: root/pango/pango-ot-ruleset.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-07-07 17:49:05 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-07-07 17:49:05 +0000
commit3c5d2feb8642715355e701767d50ddc814398019 (patch)
tree64ccc2bfc620f2191d1146053f1a788dc547e8b5 /pango/pango-ot-ruleset.c
parent54d3056aa100f9ef02e6d8239964b6cf8e0a5461 (diff)
downloadpango-3c5d2feb8642715355e701767d50ddc814398019.tar.gz
Bug 344766 – Memory leak in get_ruleset() in modules/basic/basic-fc.c
2006-07-07 Behdad Esfahbod <behdad@gnome.org> Bug 344766 – Memory leak in get_ruleset() in modules/basic/basic-fc.c * pango/pango-ot-private.h: Rename PANGO_OT_IS_RULESET is PANGO_IS_OT_RULESET. * pango/pango-ot-ruleset.c (pango_ot_ruleset_finalize), (pango_ot_ruleset_new), (pango_ot_ruleset_add_feature), (pango_ot_ruleset_substitute), (pango_ot_ruleset_position): Use weak pointers to reference ruleset->info, to avoid circular dependency.
Diffstat (limited to 'pango/pango-ot-ruleset.c')
-rw-r--r--pango/pango-ot-ruleset.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/pango/pango-ot-ruleset.c b/pango/pango-ot-ruleset.c
index e50b2a1e..521536f6 100644
--- a/pango/pango-ot-ruleset.c
+++ b/pango/pango-ot-ruleset.c
@@ -88,7 +88,8 @@ pango_ot_ruleset_finalize (GObject *object)
PangoOTRuleset *ruleset = PANGO_OT_RULESET (object);
g_array_free (ruleset->rules, TRUE);
- g_object_unref (ruleset->info);
+ if (ruleset->info)
+ g_object_remove_weak_pointer (ruleset->info, &ruleset->info);
parent_class->finalize (object);
}
@@ -107,9 +108,12 @@ pango_ot_ruleset_new (PangoOTInfo *info)
{
PangoOTRuleset *ruleset;
+ g_return_val_if_fail (info != NULL, NULL);
+
ruleset = g_object_new (PANGO_TYPE_OT_RULESET, NULL);
- ruleset->info = g_object_ref (info);
+ ruleset->info = info;
+ g_object_add_weak_pointer (ruleset->info, &ruleset->info);
return ruleset;
}
@@ -132,7 +136,8 @@ pango_ot_ruleset_add_feature (PangoOTRuleset *ruleset,
{
PangoOTRule tmp_rule;
- g_return_if_fail (PANGO_OT_IS_RULESET (ruleset));
+ g_return_if_fail (PANGO_IS_OT_RULESET (ruleset));
+ g_return_if_fail (PANGO_IS_OT_INFO (ruleset->info));
tmp_rule.table_type = table_type;
tmp_rule.feature_index = feature_index;
@@ -159,7 +164,8 @@ pango_ot_ruleset_substitute (PangoOTRuleset *ruleset,
TTO_GSUB gsub = NULL;
- g_return_if_fail (PANGO_OT_IS_RULESET (ruleset));
+ g_return_if_fail (PANGO_IS_OT_RULESET (ruleset));
+ g_return_if_fail (PANGO_IS_OT_INFO (ruleset->info));
for (i = 0; i < ruleset->rules->len; i++)
{
@@ -202,7 +208,8 @@ pango_ot_ruleset_position (PangoOTRuleset *ruleset,
TTO_GPOS gpos = NULL;
- g_return_if_fail (PANGO_OT_IS_RULESET (ruleset));
+ g_return_if_fail (PANGO_IS_OT_RULESET (ruleset));
+ g_return_if_fail (PANGO_IS_OT_INFO (ruleset->info));
for (i = 0; i < ruleset->rules->len; i++)
{