From 3ad33afa3db46e394c0a5055a7f6eff7113e8df6 Mon Sep 17 00:00:00 2001
From: Andre Noll <maan@systemlinux.org>
Date: Tue, 7 Jan 2014 16:14:12 +0000
Subject: [PATCH] gui: Shut down curses before rereading the config file.

If the config file contains errors, gui_cmdline_parser_config_file()
calls exit() while curses is still active, leading to messed up
terminal settings. Fix this by calling shutdown_curses() before
parsing the config file, and init_curses() thereafter.
---
 gui.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gui.c b/gui.c
index 5a2e659d..716e299b 100644
--- a/gui.c
+++ b/gui.c
@@ -1362,7 +1362,13 @@ static void com_reread_conf(void)
 	}
 	PARA_INFO_LOG("rereading command line options and config file");
 	gui_cmdline_parser_ext(_argc, _argv, &conf, &params);
+	/*
+	 * Despite .print_errors is set to 0, gengetopt will print to stderr
+	 * anyway, and exit on errors. So we have to shutdown curses first.
+	 */
+	shutdown_curses();
 	gui_cmdline_parser_config_file(cf, &conf, &params);
+	init_curses();
 	PARA_NOTICE_LOG("config file reloaded");
 	if (check_key_map_args() < 0)
 		finish(EXIT_FAILURE);
-- 
2.39.5