Device::setState(): clarify code, no change in logic
@@ -760,20 +760,24 @@ void Device::setState(DeviceStateHandler state, DEV_StateLevel level)
{
m_state[level](this, Event(prefix(), REventStateLeave, level, key()));
}
+
m_state[level] = state;
- if (m_state[level] && level == StateLevel0)
+
+ if (m_state[level])
+ {
+ if (level == StateLevel0)
{
// invoke the handler in the next event loop iteration
emit eventNotify(Event(prefix(), REventStateEnter, level, key()));
}
- else if (m_state[level])
+ else
{
// invoke sub-states directly
- // TODO: check might be wonky
m_state[level](this, Event(prefix(), REventStateEnter, level, key()));
}
}
}
+}
void Device::startStateTimer(int IntervalMs)
{
