Index: sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rb54264a622d738efdafe842942921b6840828914 --- sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp (.../VCommonAdjustmentVitals.cpp) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/view/hd/adjustment/common/VCommonAdjustmentVitals.cpp (.../VCommonAdjustmentVitals.cpp) (revision b54264a622d738efdafe842942921b6840828914) @@ -31,8 +31,8 @@ void View::VTreatmentVitals::initConnections() { ACTION_RECEIVE_BRIDGE_CONNECTION(_BluetoothInterface, UIBloodPressureData); - connect(this, SIGNAL( intervalChanged (const quint8 &)), - this, SLOT(onTimerChanged ( ))); + connect(this, SIGNAL( intervalChanged (const quint8 &)), + this, SLOT(onIntervalChanged ( ))); } /*! @@ -171,23 +171,26 @@ */ void View::VTreatmentVitals::timerEvent(QTimerEvent *) { + if ( ! _timerId ) return; // No timer started or failed starting if ( ! _interval ) return; // if interval is 0/OFF return - _secCounter++; - if ( _secCounter % 60 ) return; // only check every minute + // DEBUG: qDebug() << __FUNCTION__ << _counter_sec << _counter_min << _interval << _timerId; + _counter_sec++; + if ( _counter_sec % 60 ) return; // only check every minute - if ( ! _timerCounter ) { + if ( ! _counter_min ) { timerStop(); emit didTrigger(); } else { - _timerCounter--; - _secCounter = 0; + _counter_min--; + _counter_sec = 0; } } -void View::VTreatmentVitals::onTimerChanged() +void View::VTreatmentVitals::onIntervalChanged() { + // DEBUG: qDebug() << __FUNCTION__ << _counter_sec << _counter_min << _interval << _timerId; if ( _interval ) timerReset(); else timerStop (); // Timer stop is resetting timer too. } @@ -199,6 +202,10 @@ */ void View::VTreatmentVitals::timerStart() { + if ( _timerId ) killTimer(_timerId); // this typically should not happen. + if ( ! _interval ) return; // if interval is 0/OFF return + // DEBUG: qDebug() << __FUNCTION__ << _counter_sec << _counter_min << _interval << _timerId; + timerReset(); _timerId = startTimer(1000); // 1 sec interval which will used as 1 min in timerEvent (easier to debug) } @@ -207,12 +214,13 @@ { if ( _interval ) { // ( -1 ) :the interval is 0 based but if as an example we set the counter to 5 then 5 itself gets a minute to pass which makes it 6 min. - _timerCounter = _interval - 1; + _counter_min = _interval - 1; } else { // if _interval == 0, counter should set to 0 too not to -1 - _timerCounter = 0; + _counter_min = 0; } - _secCounter = 0; + _counter_sec = 0; + // DEBUG: qDebug() << __FUNCTION__ << _counter_sec << _counter_min << _interval << _timerId; } /*! @@ -221,6 +229,8 @@ */ void View::VTreatmentVitals::timerStop() { + if ( ! _timerId ) return; // No timer started or failed starting + // DEBUG: qDebug() << __FUNCTION__ << _counter_sec << _counter_min << _interval << _timerId; killTimer(_timerId); _timerId = 0; timerReset();