From 3788df6d78a42ff1c8b8bfac02dd67345d01a23b Mon Sep 17 00:00:00 2001
From: Lars Henriksen <LarsHenriksen@get2net.dk>
Date: Thu, 8 Mar 2018 20:10:41 +0100
Subject: Fix multiple, simultaneous periodic saves

A new save thread was started every time a positive periodic save value
was input in the general options configuration menu. And only one thread
can be stopped by entering 0, also when done repeatedly.

Always stop the old thread before (possibly) starting a new.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
---
 src/custom.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'src')

diff --git a/src/custom.c b/src/custom.c
index 9443365..fff83d7 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -744,12 +744,12 @@ static void general_option_edit(int i)
 		status_mesg(periodic_save_str, "");
 		if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
 			val = atoi(buf);
-			if (val >= 0)
+			if (val >= 0) {
 				conf.periodic_save = val;
-			if (conf.periodic_save > 0)
-				io_start_psave_thread();
-			else if (conf.periodic_save == 0)
 				io_stop_psave_thread();
+				if (conf.periodic_save > 0)
+					io_start_psave_thread();
+			}
 		}
 		break;
 	case CONFIRM_QUIT:
-- 
cgit v1.2.3-70-g09d2