From a2587c0d8c4ba895d779decf0239cf0f2360cc4a Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Sun, 17 Apr 2016 16:26:22 +0200 Subject: [PATCH] ComponentsTimer: ensure slot connect/disconnect dependency from slot state Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/f4eb9e45ec26a412063ea8ee567eb20f150f2609 Author: Thilo Graf Date: 2016-04-17 (Sun, 17 Apr 2016) --- src/gui/components/cc_timer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/components/cc_timer.cpp b/src/gui/components/cc_timer.cpp index f7cbfa4ad..129f19dbc 100644 --- a/src/gui/components/cc_timer.cpp +++ b/src/gui/components/cc_timer.cpp @@ -83,8 +83,10 @@ bool CComponentsTimer::startTimer() return false; } if (res == 0){ - dprintf(DEBUG_INFO,"\033[33m[CComponentsTimer] [%s - %d] timer thread [%lu] created with interval = %d\033[0m\n", __func__, __LINE__, pthread_self(), tm_interval); - CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl); + if (!sl.empty()){ + dprintf(DEBUG_INFO,"\033[33m[CComponentsTimer] [%s - %d] timer thread [%lu] created with interval = %d\033[0m\n", __func__, __LINE__, pthread_self(), tm_interval); + CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl); + } }else{ dprintf(DEBUG_NORMAL, "\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_create\033[0m\n", __func__, __LINE__); } @@ -107,9 +109,12 @@ bool CComponentsTimer::stopTimer() if (thres == 0){ tm_thread = 0; + dprintf(DEBUG_INFO,"\033[33m[CComponentsTimer] [%s] timer thread terminated ...\033[0m\n", __func__); //ensure disconnect of unused slot - sl.disconnect(); - dprintf(DEBUG_INFO,"\033[33m[CComponentsTimer] [%s] timer thread terminated ...\033[0m\n", __func__); + if (!sl.empty()){ + dprintf(DEBUG_INFO,"\033[33m[CComponentsTimer][%s] disconnect timer slot ...\033[0m\n", __func__); + sl.disconnect(); + } return true; } }