Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/sugar/tutorius/core.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/sugar/tutorius/core.py')
-rw-r--r--src/sugar/tutorius/core.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/sugar/tutorius/core.py b/src/sugar/tutorius/core.py
index f290f1e..602947f 100644
--- a/src/sugar/tutorius/core.py
+++ b/src/sugar/tutorius/core.py
@@ -295,11 +295,8 @@ class FiniteStateMachine(State):
self._states = state_dict or {}
self.start_state_name = start_state_name
- # If we have a filled input dictionary
- if len(self._states) > 0:
- self.current_state = self._states[self.start_state_name]
- else:
- self.current_state = None
+ # Set the current state to None - we are not executing anything yet
+ self.current_state = None
# Register the actions for the FSM - They will be processed at the
# FSM level, meaning that when the FSM will start, it will first
@@ -375,6 +372,13 @@ class FiniteStateMachine(State):
# state by that name - we must ignore this state change request as
# it will be done elsewhere in the hierarchy (or it's just bogus).
return
+
+ if self.current_state != None:
+ if new_state_name == self.current_state.name:
+ # If we already are in this state, we do not need to change
+ # anything in the current state - By design, a state may not point
+ # to itself
+ return
new_state = self._states[new_state_name]