diff --git a/powerman/action.cpp b/powerman/action.cpp index de64432..432eb86 100644 --- a/powerman/action.cpp +++ b/powerman/action.cpp @@ -48,6 +48,12 @@ void Action::registerIdleTimeout(int msec) IdleManager::self()->registerActionTimeout(this, msec); } +void Action::unregisterIdleTimeout() +{ + d->registeredIdleTimeouts.clear(); + IdleManager::self()->unregisterActionTimeouts(this); +} + bool Action::isSupported() { return true; diff --git a/powerman/action.h b/powerman/action.h index 141acac..56dc3f4 100644 --- a/powerman/action.h +++ b/powerman/action.h @@ -63,6 +63,8 @@ protected: */ void registerIdleTimeout(int msec); + void unregisterIdleTimeout(); + public Q_SLOTS: /** * This slot is triggered whenever an idle timeout registered with registerIdleTimeout is reached. diff --git a/powerman/dimdisplayaction.cpp b/powerman/dimdisplayaction.cpp index 5f52efb..c0a3a1e 100644 --- a/powerman/dimdisplayaction.cpp +++ b/powerman/dimdisplayaction.cpp @@ -82,6 +82,13 @@ void DimDisplayAction::onIdleTimeout(int msec) void DimDisplayAction::setTimeout(int timeout) { + unregisterIdleTimeout(); + + if (timeout < 0) { + m_dimOnIdleTime = timeout; + return; + } + m_dimOnIdleTime = timeout; registerIdleTimeout(m_dimOnIdleTime * 3 / 4); registerIdleTimeout(m_dimOnIdleTime / 2);