From 3cd509aa2db2730b756bc947bdc4c87cb1340fb2 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 27 Dec 2016 11:30:58 +0100 Subject: [PATCH] CComponentsTimer: disconnecting slots before stop timer thread, show error Disconnecting of slots before stop threads ensures disconnecting also on thread errors and keeps timer slots clear. --- src/gui/components/cc_timer.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/components/cc_timer.cpp b/src/gui/components/cc_timer.cpp index 9c8b1aa7b..566a829e1 100644 --- a/src/gui/components/cc_timer.cpp +++ b/src/gui/components/cc_timer.cpp @@ -107,22 +107,22 @@ void CComponentsTimer::initThread() void CComponentsTimer::stopThread() { + //ensure disconnecting possible slots + while (!sl_stop_timer.empty()) + sl_stop_timer.disconnect(); + if(tm_thread) { int thres = pthread_cancel(tm_thread); if (thres != 0) - dprintf(DEBUG_NORMAL,"\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_cancel\033[0m\n", __func__, __LINE__); + dprintf(DEBUG_NORMAL,"\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_cancel, [%d]\033[0m\n", __func__, __LINE__, thres); thres = pthread_join(tm_thread, NULL); if (thres != 0) - dprintf(DEBUG_NORMAL, "\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_join\033[0m\n", __func__, __LINE__); + dprintf(DEBUG_NORMAL, "\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_join, [%d]\033[0m\n", __func__, __LINE__, thres); - if (thres == 0){ + if (thres == 0) tm_thread = 0; - //ensure disconnect of unused slot - while (!sl_stop_timer.empty()) - sl_stop_timer.disconnect(); - } } }