[glib] Allow NULL to be stored into GSettings trees



commit a38c97af519caa928a7d61af79c323a4ee2d8dfe
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat May 7 11:41:19 2011 +0200

    Allow NULL to be stored into GSettings trees
    
    This is used for resets (in theory) and currently it crashes when
    freeing the tree.

 gio/gsettingsbackend.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index 553eda0..ef2c70e 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -918,6 +918,13 @@ g_settings_backend_class_init (GSettingsBackendClass *class)
   g_type_class_add_private (class, sizeof (GSettingsBackendPrivate));
 }
 
+static void
+g_settings_backend_variant_unref0 (gpointer data)
+{
+  if (data != NULL)
+    g_variant_unref (data);
+}
+
 /*< private >
  * g_settings_backend_create_tree:
  * @returns: a new #GTree
@@ -930,7 +937,7 @@ GTree *
 g_settings_backend_create_tree (void)
 {
   return g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
-                          g_free, (GDestroyNotify) g_variant_unref);
+                          g_free, g_settings_backend_variant_unref0);
 }
 
 /**



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