[glib/new-gsettings] delayed: fix issues found by test



commit b7db858c047c0de87d26828559049c05dd73307c
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Apr 16 08:42:20 2010 -0400

    delayed: fix issues found by test
    
    gsettings: remove dead code
    test: don't leak in a way that causes test failures

 gio/gdelayedsettingsbackend.c |    8 +++++---
 gio/gsettings.c               |   25 ++-----------------------
 gio/tests/gsettings.c         |   16 ++++++++++++++++
 3 files changed, 23 insertions(+), 26 deletions(-)
---
diff --git a/gio/gdelayedsettingsbackend.c b/gio/gdelayedsettingsbackend.c
index cd50b9d..19297af 100644
--- a/gio/gdelayedsettingsbackend.c
+++ b/gio/gdelayedsettingsbackend.c
@@ -157,7 +157,8 @@ g_delayed_settings_backend_apply (GDelayedSettingsBackend *delayed)
                                      tmp, delayed->priv);
       g_tree_unref (tmp);
 
-      g_object_notify (G_OBJECT (delayed), "has-unapplied");
+      if (delayed->priv->owner)
+        g_object_notify (delayed->priv->owner, "has-unapplied");
     }
 }
 
@@ -173,7 +174,8 @@ g_delayed_settings_backend_revert (GDelayedSettingsBackend *delayed)
       g_settings_backend_changed_tree (G_SETTINGS_BACKEND (delayed), tmp, NULL);
       g_tree_destroy (tmp);
 
-      g_object_notify (G_OBJECT (delayed), "has-unapplied");
+      if (delayed->priv->owner)
+        g_object_notify (delayed->priv->owner, "has-unapplied");
     }
 }
 
@@ -269,7 +271,7 @@ g_delayed_settings_backend_class_init (GDelayedSettingsBackendClass *class)
   backend_class->reset_path = g_delayed_settings_backend_reset_path;
   backend_class->get_writable = g_delayed_settings_backend_get_writable;
   backend_class->subscribe = g_delayed_settings_backend_subscribe;
-  backend_class->unsubscribe = g_delayed_settings_backend_subscribe;
+  backend_class->unsubscribe = g_delayed_settings_backend_unsubscribe;
 
   object_class->finalize = g_delayed_settings_backend_finalize;
 }
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 6699459..f3648d3 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -114,8 +114,7 @@ struct _GSettingsPrivate
   gchar *context;
   gchar *path;
 
-  guint unapplied_handler;
-  gboolean delayed;
+  GDelayedSettingsBackend *delayed;
 };
 
 enum
@@ -242,6 +241,7 @@ settings_backend_writable_changed (GSettingsBackend *backend,
       const gchar *string;
       GQuark quark;
 
+      quark = g_quark_from_string (key + i);
       string = g_quark_to_string (quark);
 
       quark = g_quark_from_string (key + i);
@@ -358,12 +358,6 @@ g_settings_init (GSettings *settings)
                                                 GSettingsPrivate);
 }
 
-static void
-g_settings_notify_unapplied (GSettings *settings)
-{
-  g_object_notify (G_OBJECT (settings), "has-unapplied");
-}
-
 /**
  * g_settings_set_delay_apply:
  * @settings: a #GSettings object
@@ -397,21 +391,6 @@ g_settings_delay (GSettings *settings)
 }
 
 /**
- * g_settings_get_delay_apply:
- * @settings: a #GSettings object
- * @returns: %TRUE if changes in @settings are not applied immediately
- *
- * Returns whether the #GSettings object is in 'delay-apply' mode.
- *
- * Since: 2.26
- */
-gboolean
-g_settings_get_delay_apply (GSettings *settings)
-{
-  return settings->priv->delayed;
-}
-
-/**
  * g_settings_apply:
  * @settings: a #GSettings instance
  *
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index beddc26..0c573d3 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -36,6 +36,7 @@ test_basic (void)
   str = NULL;
 
   g_settings_set (settings, "greeting", "s", "this is the end");
+  g_object_unref (settings);
 }
 
 static void
@@ -205,6 +206,7 @@ test_basic_types (void)
 
   g_settings_get (settings, "test-objectpath", "o", &str);
   g_assert_cmpstr (str, ==, "/a/object/path");
+  g_object_unref (settings);
   g_free (str);
   str = NULL;
 }
@@ -250,6 +252,8 @@ test_complex_types (void)
   g_assert_cmpint (i1, ==, 5);
   g_assert (!g_variant_iter_next (iter, "i", &i1));
   g_variant_iter_free (iter);
+
+  g_object_unref (settings);
 }
 
 static gboolean changed_cb_called;
@@ -287,6 +291,8 @@ test_changes (void)
   g_settings_set (settings2, "greeting", "s", "hi");
   g_assert (changed_cb_called);
 
+  g_object_unref (settings2);
+  g_object_unref (settings);
 }
 
 static gboolean changed_cb_called2;
@@ -362,6 +368,9 @@ test_delay_apply (void)
 
   g_assert (!g_settings_get_has_unapplied (settings));
   g_assert (!g_settings_get_has_unapplied (settings2));
+
+  g_object_unref (settings2);
+  g_object_unref (settings);
 }
 
 static void
@@ -401,6 +410,9 @@ test_delay_revert (void)
   g_assert_cmpstr (str, ==, "top o' the morning");
   g_free (str);
   str = NULL;
+
+  g_object_unref (settings2);
+  g_object_unref (settings);
 }
 
 static void
@@ -472,6 +484,9 @@ test_atomic (void)
   g_assert_cmpstr (str, ==, "atomic bye-bye");
   g_free (str);
   str = NULL;
+
+  g_object_unref (settings2);
+  g_object_unref (settings);
 }
 
 static gboolean
@@ -522,6 +537,7 @@ test_l10n (void)
   setlocale (LC_MESSAGES, locale);
 
   g_assert_cmpstr (str, ==, "Unbenannt");
+  g_object_unref (settings);
   g_free (str);
   str = NULL;
 



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