summaryrefslogtreecommitdiff
path: root/pango/pango-ot-ruleset.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-07-07 17:48:16 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-07-07 17:48:16 +0000
commit35a7c23baabda073fea6da3a593fb718c9ac8c89 (patch)
treed653ba0a0ae44d416ea38c2c071a846c0c44e2cf /pango/pango-ot-ruleset.c
parentd6c52d269cd0675fbd97d51b8ff8591d52f2b577 (diff)
downloadpango-35a7c23baabda073fea6da3a593fb718c9ac8c89.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 da876e35..449dfd0b 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;
}
@@ -133,7 +137,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;
@@ -160,7 +165,8 @@ pango_ot_ruleset_substitute (PangoOTRuleset *ruleset,
HB_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++)
{
@@ -203,7 +209,8 @@ pango_ot_ruleset_position (PangoOTRuleset *ruleset,
HB_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++)
{