[glib] GSettings: peek instead of ref/unref enum class



commit ab1111b8bbb7a6057248658013eb23d80f4721cf
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Jun 28 13:58:25 2010 -0400

    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 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gio/gsettings-mapping.c b/gio/gsettings-mapping.c
index bbca56f..52a9b21 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)
             {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]