From 6fa568daae3291c7a876cd903f04079a12945dcb Mon Sep 17 00:00:00 2001 From: mike Date: Tue, 05 May 2009 05:44:27 +0000 Subject: Merge branch 'mike' Conflicts: source/external/source/sugar-toolkit/src/sugar/tutorius/actions.py source/external/source/sugar-toolkit/src/sugar/tutorius/tests/actiontests.py source/external/source/sugar-toolkit/src/sugar/tutorius/tests/run-tests.py --- (limited to 'src/sugar/tutorius/core.py') 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] -- cgit v0.9.1