[dconf] engine, gsettings: prevent empty changesets



commit 4c516a76f55d75ecfa1b985adb1905cac945f3fe
Author: Ryan Lortie <desrt desrt ca>
Date:   Mon Feb 4 12:37:49 2013 +0100

    engine, gsettings: prevent empty changesets
    
    We should not send empty changesets to the service so just ignore them
    when we get them.
    
    This now means that an empty 'dconf load' will not send any D-Bus
    messages (and will not cause D-Bus activation).

 client/dconf-client.c            |    3 ++-
 engine/dconf-engine.c            |   11 +++++++++++
 gsettings/dconfsettingsbackend.c |    6 ++++--
 3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/client/dconf-client.c b/client/dconf-client.c
index c7c2e9e..534132f 100644
--- a/client/dconf-client.c
+++ b/client/dconf-client.c
@@ -441,7 +441,8 @@ dconf_client_change_fast (DConfClient     *client,
  *
  * If @tag is non-%NULL then it is set to the unique tag associated with
  * this change.  This is the same tag that will appear in the following
- * change signal.
+ * change signal.  If @changeset makes no changes then @tag may be
+ * non-unique (eg: the empty string may be used for empty changesets).
  *
  * Returns: %TRUE on success, else %FALSE with @error set
  **/
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index 45e1d66..446619e 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -1029,6 +1029,9 @@ dconf_engine_change_fast (DConfEngine     *engine,
 {
   GList *node;
 
+  if (dconf_changeset_is_empty (changeset))
+    return TRUE;
+
   if (!dconf_engine_changeset_changes_only_writable_keys (engine, changeset, error))
     return FALSE;
 
@@ -1091,6 +1094,14 @@ dconf_engine_change_sync (DConfEngine     *engine,
 {
   GVariant *reply;
 
+  if (dconf_changeset_is_empty (changeset))
+    {
+      if (tag)
+        *tag = g_strdup ("");
+
+      return TRUE;
+    }
+
   if (!dconf_engine_changeset_changes_only_writable_keys (engine, changeset, error))
     return FALSE;
 
diff --git a/gsettings/dconfsettingsbackend.c b/gsettings/dconfsettingsbackend.c
index c8273f9..53f701e 100644
--- a/gsettings/dconfsettingsbackend.c
+++ b/gsettings/dconfsettingsbackend.c
@@ -101,9 +101,11 @@ dconf_settings_backend_write_tree (GSettingsBackend *backend,
   DConfChangeset *change;
   gboolean success;
 
-  change= dconf_changeset_new ();
-  g_tree_foreach (tree, dconf_settings_backend_add_to_changeset, change);
+  if (g_tree_nnodes (tree) == 0)
+    return TRUE;
 
+  change = dconf_changeset_new ();
+  g_tree_foreach (tree, dconf_settings_backend_add_to_changeset, change);
   success = dconf_engine_change_fast (dcsb->engine, change, origin_tag, NULL);
   dconf_changeset_unref (change);
 


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