Avoid starting the notification thread twice

Starting the notification thread more than once can result in strange
behavior. For example, when launching external commands, only the most
recently started thread is stopped which results in the external
command's screen output being overwritten by the notification bar.

Currently, there are a couple of situations where the thread is started
twice. As a first countermeasure, explicitly check whether the thread is
already running (and terminate it) before starting a new one.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer 2016-08-24 21:44:47 +02:00
parent 8fe9dd1c2b
commit e6f8a2932a

View File

@ -549,6 +549,9 @@ int notify_same_recur_item(struct recur_apoint *i)
/* Launch the notify-bar main thread. */ /* Launch the notify-bar main thread. */
void notify_start_main_thread(void) void notify_start_main_thread(void)
{ {
/* Avoid starting the notification bar thread twice. */
notify_stop_main_thread();
pthread_create(&notify_t_main, NULL, notify_main_thread, NULL); pthread_create(&notify_t_main, NULL, notify_main_thread, NULL);
notify_check_next_app(0); notify_check_next_app(0);
} }