From 4e232774b2e8ef095764417d1e242590749fb099 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Tue, 19 Apr 2011 09:53:35 +0400 Subject: [PATCH] Ticket #2541: MC saves configuration many times. The problem: when mc quits with auto-save setup, the main confguration file is written 4 times. The solution: don't write ini when some part of setup is saved. Write ini only after save whole confguration. Signed-off-by: Andrew Borodin --- src/filemanager/cmd.c | 3 +++ src/filemanager/panelize.c | 1 - src/setup.c | 14 -------------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/filemanager/cmd.c b/src/filemanager/cmd.c index 8d1f76026..291d37c4d 100644 --- a/src/filemanager/cmd.c +++ b/src/filemanager/cmd.c @@ -1571,6 +1571,9 @@ save_setup_cmd (void) if (save_setup (TRUE, TRUE)) message (D_NORMAL, _("Setup"), _("Setup saved to %s%s%s"), mc_config_get_path (), PATH_SEP_STR, MC_CONFIG_FILE); + else + message (D_ERROR, _("Setup"), _("Unable to save setup to %s%s%s"), + mc_config_get_path (), PATH_SEP_STR, MC_CONFIG_FILE); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c index 9d2fb969e..7acbbe514 100644 --- a/src/filemanager/panelize.c +++ b/src/filemanager/panelize.c @@ -515,7 +515,6 @@ save_panelize (void) mc_config_set_string (mc_main_config, panelize_section, current->label, current->command); } - mc_config_save_file (mc_main_config, NULL); } /* --------------------------------------------------------------------------------------------- */ diff --git a/src/setup.c b/src/setup.c index 2d7dad78a..8a775c712 100644 --- a/src/setup.c +++ b/src/setup.c @@ -1008,7 +1008,6 @@ save_setup (gboolean save_options, gboolean save_panel_options) tmp_profile = g_build_filename (mc_config_get_path (), MC_CONFIG_FILE, NULL); ret = mc_config_save_to_file (mc_main_config, tmp_profile, NULL); - g_free (tmp_profile); } @@ -1056,12 +1055,8 @@ done_setup (void) void save_config (void) { - char *profile; - GError *error = NULL; size_t i; - profile = g_build_filename (mc_config_get_path (), MC_CONFIG_FILE, NULL); - /* Save integer options */ for (i = 0; int_options[i].opt_name != NULL; i++) mc_config_set_int (mc_main_config, CONFIG_APP_SECTION, int_options[i].opt_name, @@ -1071,11 +1066,6 @@ save_config (void) for (i = 0; str_options[i].opt_name != NULL; i++) mc_config_set_string (mc_main_config, CONFIG_APP_SECTION, str_options[i].opt_name, *str_options[i].opt_addr); - - if (!mc_config_save_to_file (mc_main_config, profile, &error)) - setup_save_config_show_error (profile, &error); - - g_free (profile); } /* --------------------------------------------------------------------------------------------- */ @@ -1096,15 +1086,11 @@ setup_save_config_show_error (const char *filename, GError ** error) void save_layout (void) { - char *profile; size_t i; - profile = g_build_filename (mc_config_get_path (), MC_CONFIG_FILE, NULL); /* Save integer options */ for (i = 0; layout[i].opt_name != NULL; i++) mc_config_set_int (mc_main_config, "Layout", layout[i].opt_name, *layout[i].opt_addr); - mc_config_save_to_file (mc_main_config, profile, NULL); - g_free (profile); } /* --------------------------------------------------------------------------------------------- */ -- 2.11.4.GIT