From: Andre Noll <maan@tuebingen.mpg.de>
Date: Sat, 14 Feb 2015 19:45:29 +0000 (+0100)
Subject: gui: Fix config file reloading.
X-Git-Tag: v0.5.5~56^2
X-Git-Url: https://git.tue.mpg.de/?a=commitdiff_plain;h=700dc3cf050893acd234a74e617ff2e4b2082f31;p=paraslash.git

gui: Fix config file reloading.

Without this, all key-map arguments found in the config file are
appended to the existing ones, duplicating these options in the help
output. Fix this by invalidating the key-map entry prior to the call
to gui_cmdline_parser_config_file().

This bug was present since "day one".
---

diff --git a/gui.c b/gui.c
index c82cd8c3..1a89681d 100644
--- a/gui.c
+++ b/gui.c
@@ -871,6 +871,23 @@ static void parse_config_file_or_die(bool override)
 		}
 		goto out;
 	}
+	/*
+	 * When the gengetopt config file parser is called more than once, any
+	 * key map arguments found in the config file are _appended_ to the old
+	 * values, even though we turn on ->override. We want the new arguments
+	 * to replace the old ones, so we must empty the key_map_arg array
+	 * first. Unfortunately, this also clears any key map arguments given
+	 * at the command line.
+	 */
+	if (override) {
+		int i;
+		for (i = 0; i < conf.key_map_given; i++) {
+			free(conf.key_map_arg[i]);
+			conf.key_map_arg[i] = NULL;
+		}
+		conf.key_map_given = 0;
+	}
+
 	gui_cmdline_parser_config_file(config_file, &conf, &params);
 	loglevel = get_loglevel_by_name(conf.loglevel_arg);
 	check_key_map_args_or_die();