]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
gui: Don't exit without shutting down curses on config reload.
authorAndre Noll <maan@systemlinux.org>
Tue, 18 Jan 2011 21:36:32 +0000 (22:36 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 11 Feb 2011 10:25:07 +0000 (11:25 +0100)
Currently, if a config file containing errors is being reloaded,
gui_cmdline_parser_ext() calls exit() which leaves the terminal
in an unusable state because para_gui had no chance to call
endwin() in order to reset the terminal.

Fix this flaw by instructing gengetopt to generate code that does
not exit on errors. We can still tell that the command line or the
config file contained errors by looking at the return value of the
various parsers.

ggo/makefile
gui.c

index d4f3a8cd2d212b281aff3c4282bb9e497a3c3297..d5a1d645cd79db1b177e2f46cd67dbffe765cecf 100644 (file)
@@ -29,6 +29,7 @@ $(cmdline_dir)/%_write.cmdline.h $(cmdline_dir)/%_write.cmdline.c: $(ggo_dir)/%_
                --func-name $(subst _write.ggo,,$(<F))_cmdline_parser < $<
 
 define ggo-opts
+$(if $(filter gui,$(*F)), --no-handle-error) \
 $(if $(filter recv filter write audiod,$(*F)), --no-handle-help) \
 $(if $(filter afh,$(*F)), --unamed-opts=audio_file) \
 $(if $(filter client audioc,$(*F)), --unamed-opts=command) \
diff --git a/gui.c b/gui.c
index fe580864faf7f9c9f3092bdb0d637b183f9e9400..3b001a7da191a7c5f52a177ee73e0045c81ce05c 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -1228,7 +1228,8 @@ static void com_reread_conf(void)
                .override = 1,
                .initialize = 1,
                .check_required = 0,
-               .check_ambiguity = 0
+               .check_ambiguity = 0,
+               .print_errors = 0,
        };
 
        if (!cf) {
@@ -1236,8 +1237,11 @@ static void com_reread_conf(void)
                return;
        }
        PARA_INFO_LOG("rereading command line options and config file");
-       gui_cmdline_parser(_argc, _argv, &conf);
-       gui_cmdline_parser_config_file(cf, &conf, &params);
+       gui_cmdline_parser_ext(_argc, _argv, &conf, &params);
+       if (gui_cmdline_parser_config_file(cf, &conf, &params) != 0) {
+               PARA_EMERG_LOG("errors in config file");
+               finish(EXIT_FAILURE);
+       }
        PARA_NOTICE_LOG("config file reloaded");
        if (check_key_map_args() < 0)
                finish(EXIT_FAILURE);
@@ -1394,7 +1398,8 @@ int main(int argc, char *argv[])
        _argc = argc;
        _argv = argv;
 
-       gui_cmdline_parser(argc, argv, &conf);
+       if (gui_cmdline_parser(argc, argv, &conf) != 0)
+               exit(EXIT_FAILURE);
        HANDLE_VERSION_FLAG("gui", conf);
        cf = configfile_exists();
        if (!cf && conf.config_file_given) {
@@ -1410,7 +1415,8 @@ int main(int argc, char *argv[])
                        .check_ambiguity = 0,
                        .print_errors = 1,
                };
-               gui_cmdline_parser_config_file(cf, &conf, &params);
+               if (gui_cmdline_parser_config_file(cf, &conf, &params) != 0)
+                       exit(EXIT_FAILURE);
        }
        loglevel = get_loglevel_by_name(conf.loglevel_arg);
        if (check_key_map_args() < 0) {