From 0a155905ee349970d731aaa17fef9321f671ca9f Mon Sep 17 00:00:00 2001 From: CarlWachter Date: Mon, 2 Sep 2024 09:28:24 +0200 Subject: [PATCH] fix: force transition no longer restarts same state --- src/statemachine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/statemachine.cpp b/src/statemachine.cpp index 4116f45..6df4e93 100644 --- a/src/statemachine.cpp +++ b/src/statemachine.cpp @@ -72,7 +72,8 @@ namespace sta transition.event = EventFlags::NORMAL; transition.lockout = lockout; - if (force){ + // Force the transition if requested, but only if the requested state is different from the current one. + if (force && transition.to != currentState_){ // Perform the transition and notify the threads. The event flags are set // here in order to allow threads to react immediately. currentState_ = transition.to;