ComponentsTimer: ensure slot connect/disconnect dependency from slot state

Origin commit data
------------------
Commit: f4eb9e45ec
Author: Thilo Graf <dbt@novatux.de>
Date: 2016-04-17 (Sun, 17 Apr 2016)
This commit is contained in:
2016-04-17 16:26:22 +02:00
parent 58356ce4e3
commit a2587c0d8c

View File

@@ -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;
}
}