summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2012-07-06 14:11:01 -0400
committerRyan Lortie <desrt@desrt.ca>2012-07-06 14:37:53 -0400
commitd83db37547286b2234022492d2580f9463ae81cc (patch)
tree8a7a0ff86b3130b4bf2494bd4e5e3f1536156c9f /common
parent2e5a3580c826928bcd73493c0dfb6275376eeb2c (diff)
downloaddconf-d83db37547286b2234022492d2580f9463ae81cc.tar.gz
DConfChangeset: fix bugs found by test
Fix a few bugs found by the new testcase.
Diffstat (limited to 'common')
-rw-r--r--common/dconf-changeset.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/common/dconf-changeset.c b/common/dconf-changeset.c
index b8ba126..481a82e 100644
--- a/common/dconf-changeset.c
+++ b/common/dconf-changeset.c
@@ -35,6 +35,13 @@ struct _DConfChangeset
GVariant **values;
};
+static void
+unref_gvariant0 (gpointer data)
+{
+ if (data)
+ g_variant_unref (data);
+}
+
/**
* dconf_changeset_new:
*
@@ -48,7 +55,7 @@ dconf_changeset_new (void)
DConfChangeset *change;
change = g_slice_new0 (DConfChangeset);
- change->table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
+ change->table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, unref_gvariant0);
change->ref_count = 1;
return change;
@@ -100,6 +107,8 @@ dconf_changeset_set (DConfChangeset *change,
GVariant *value)
{
g_return_if_fail (change->root == NULL);
+ g_return_if_fail (key != NULL);
+ g_return_if_fail (key[0] == '/');
g_hash_table_insert (change->table, g_strdup (key), value ? g_variant_ref_sink (value) : NULL);
}
@@ -150,6 +159,11 @@ dconf_changeset_get (DConfChangeset *change,
* of the same keys. This is often seen when an application writes to a
* key on every move of a slider or an application window.
*
+ * Strictly speaking, a write resettings all of "/a/" after a write
+ * containing "/a/b" could cause the later to be removed from the queue,
+ * but this situation is difficult to detect and is expected to be
+ * extremely rare.
+ *
* Returns: %TRUE if the changes are similar
**/
gboolean
@@ -208,7 +222,7 @@ dconf_changeset_string_ptr_compare (gconstpointer a_p,
gconstpointer b_p)
{
const gchar * const *a = a_p;
- const gchar * const *b = a_p;
+ const gchar * const *b = b_p;
return strcmp (*a, *b);
}
@@ -261,7 +275,7 @@ dconf_changeset_build_description (DConfChangeset *change)
first = key;
/* Consider the remaining items to find the common prefix */
- while (g_hash_table_iter_next (&iter, key, NULL))
+ while (g_hash_table_iter_next (&iter, &key, NULL))
{
const gchar *this = key;
gint i;