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:
authormike <michael.jmontcalm@gmail.com>2009-03-26 20:39:40 (GMT)
committer mike <michael.jmontcalm@gmail.com>2009-04-16 00:52:37 (GMT)
commitaefa4024904ec92034d108d94768a388e8f1a9f6 (patch)
tree43a67eabda3ba630bce0fc7cb05719989263ddfa /src/sugar/tutorius/core.py
parentc99f5b852adb347dfc9c1c494f85c42921b4229e (diff)
TutoriusV2 : Added test for set_state with same name twice - corrected core behavior in this case
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 901820f..4d53684 100644
--- a/src/sugar/tutorius/core.py
+++ b/src/sugar/tutorius/core.py
@@ -277,11 +277,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
@@ -357,6 +354,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]