File gnome-control-center-bnc486093-create-backup-file.diff of Package gnome-control-center
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index 132a3cd..dd33524 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -1771,6 +1771,31 @@ begin_version1_apply_configuration (App *app)
*/
}
+static void
+ensure_current_configuration_is_saved (void)
+{
+ GnomeRRScreen *rr_screen;
+ GnomeRRConfig *rr_config;
+
+ /* Normally, gnome_rr_config_save() creates a backup file based on the
+ * old monitors.xml. However, if *that* file didn't exist, there is
+ * nothing from which to create a backup. So, here we'll save the
+ * current/unchanged configuration and then let our caller call
+ * gnome_rr_config_save() again with the new/changed configuration, so
+ * that there *will* be a backup file in the end.
+ */
+
+ rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL, NULL, NULL); /* NULL-GError */
+ if (!rr_screen)
+ return;
+
+ rr_config = gnome_rr_config_new_current (rr_screen);
+ gnome_rr_config_save (rr_config, NULL); /* NULL-GError */
+
+ gnome_rr_config_free (rr_config);
+ gnome_rr_screen_destroy (rr_screen);
+}
+
/* Callback for dbus_g_proxy_begin_call() */
static void
apply_configuration_returned_cb (DBusGProxy *proxy,
@@ -1823,6 +1848,8 @@ apply (App *app)
foo_scroll_area_invalidate (FOO_SCROLL_AREA (app->area));
+ ensure_current_configuration_is_saved ();
+
if (!gnome_rr_config_save (app->current_configuration, &error))
{
error_message (app, _("Could not save the monitor configuration"), error->message);