From ab1111b8bbb7a6057248658013eb23d80f4721cf Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Mon, 28 Jun 2010 13:58:25 -0400 Subject: [PATCH] GSettings: peek instead of ref/unref enum class We only ever do the enum mapping for the property binding in the case that a GParamSpecEnum exists and in that case the class is already referenced by the GParamSpec. Use peek instead of ref/unref and add a clarifying note. --- gio/gsettings-mapping.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gio/gsettings-mapping.c b/gio/gsettings-mapping.c index bbca56f01..52a9b218f 100644 --- a/gio/gsettings-mapping.c +++ b/gio/gsettings-mapping.c @@ -382,9 +382,9 @@ g_settings_set_mapping (const GValue *value, GEnumValue *enumval; GEnumClass *eclass; - eclass = g_type_class_ref (G_VALUE_TYPE (value)); + /* GParamSpecEnum holds a ref on the class so we just peek... */ + eclass = g_type_class_peek (G_VALUE_TYPE (value)); enumval = g_enum_get_value (eclass, g_value_get_enum (value)); - g_type_class_unref (eclass); if (enumval) return g_variant_new_string (enumval->value_nick); @@ -454,10 +454,10 @@ g_settings_get_mapping (GValue *value, GEnumValue *evalue; const gchar *nick; - eclass = g_type_class_ref (G_VALUE_TYPE (value)); + /* GParamSpecEnum holds a ref on the class so we just peek... */ + eclass = g_type_class_peek (G_VALUE_TYPE (value)); nick = g_variant_get_string (variant, NULL); evalue = g_enum_get_value_by_nick (eclass, nick); - g_type_class_unref (eclass); if (evalue) {