gsettings-tool: warn if setting a value fails
authorDan Winship <danw@gnome.org>
Fri, 11 Mar 2011 03:09:31 +0000 (22:09 -0500)
committerDan Winship <danw@gnome.org>
Sat, 9 Apr 2011 16:45:16 +0000 (12:45 -0400)
eg, if the dconf backend cannot connect to dbus

https://bugzilla.gnome.org/show_bug.cgi?id=641768

gio/gsettings-tool.c

index 14bd99f..a5d43a4 100644 (file)
@@ -409,6 +409,7 @@ gsettings_set (GSettings   *settings,
   GError *error = NULL;
   GVariant *existing;
   GVariant *new;
+  GVariant *stored;
   gchar *freeme = NULL;
 
   existing = g_settings_get_value (settings, key);
@@ -442,16 +443,23 @@ gsettings_set (GSettings   *settings,
   if (!g_settings_range_check (settings, key, new))
     {
       g_printerr (_("The provided value is outside of the valid range\n"));
-      g_variant_unref (new);
       exit (1);
     }
 
   g_settings_set_value (settings, key, new);
+  g_settings_sync ();
+
+  stored = g_settings_get_value (settings, key);
+  if (g_variant_equal (stored, existing))
+    {
+      g_printerr (_("Failed to set value\n"));
+      exit (1);
+    }
+
+  g_variant_unref (stored);
   g_variant_unref (existing);
   g_variant_unref (new);
 
-  g_settings_sync ();
-
   g_free (freeme);
 }