From f17f57eb0e74b73c96bd1fe4eeb3344e920a3a8b Mon Sep 17 00:00:00 2001 From: Christian Schuett Date: Mon, 30 Dec 2013 22:41:26 +0100 Subject: [PATCH] Neutrino sleeptimer: speed up timer deletion Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/0a195c7c4855761b5cc84598e84fe5663fab2e10 Author: Christian Schuett Date: 2013-12-30 (Mon, 30 Dec 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/sleeptimer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gui/sleeptimer.cpp b/src/gui/sleeptimer.cpp index b34caddde..8779552cd 100644 --- a/src/gui/sleeptimer.cpp +++ b/src/gui/sleeptimer.cpp @@ -108,12 +108,15 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) printf("sleeptimer min: %d\n", shutdown_min); if (shutdown_min == 0) // if set to zero remove existing sleeptimer { - if(g_Timerd->getSleeptimerID() > 0) { - g_Timerd->removeTimerEvent(g_Timerd->getSleeptimerID()); - } + int timer_id = g_Timerd->getSleeptimerID(); + if (timer_id > 0) + g_Timerd->removeTimerEvent(timer_id); } else // set the sleeptimer to actual time + shutdown mins and announce 1 min before - g_Timerd->setSleeptimer(time(NULL) + ((shutdown_min -1) * 60),time(NULL) + shutdown_min * 60,0); + { + time_t now = time(NULL); + g_Timerd->setSleeptimer(now + (shutdown_min - 1) * 60, now + shutdown_min * 60, 0); + } } is_running = false;