Index: code/branches/gui/src/core/input/InputManager.cc
===================================================================
--- code/branches/gui/src/core/input/InputManager.cc	(revision 2848)
+++ code/branches/gui/src/core/input/InputManager.cc	(revision 2849)
@@ -747,14 +747,14 @@
         if (!stateLeaveRequests_.empty())
         {
-            for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin();
-                rit != stateLeaveRequests_.rend(); ++rit)
-            {
-                (*rit)->onLeave();
+            for (std::set<InputState*>::iterator it = stateLeaveRequests_.begin();
+                it != stateLeaveRequests_.end(); ++it)
+            {
+                (*it)->onLeave();
                 // just to be sure that the state actually is registered
-                assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
-
-                activeStates_.erase((*rit)->getPriority());
-                if ((*rit)->getPriority() < InputStatePriority::HighPriority)
-                    (*rit)->setPriority(0);
+                assert(inputStatesByName_.find((*it)->getName()) != inputStatesByName_.end());
+
+                activeStates_.erase((*it)->getPriority());
+                if ((*it)->getPriority() < InputStatePriority::HighPriority)
+                    (*it)->setPriority(0);
                 _updateActiveStates();
             }
@@ -765,29 +765,29 @@
         if (!stateEnterRequests_.empty())
         {
-            for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin();
-                rit != stateEnterRequests_.rend(); ++rit)
+            for (std::set<InputState*>::const_iterator it = stateEnterRequests_.begin();
+                it != stateEnterRequests_.end(); ++it)
             {
                 // just to be sure that the state actually is registered
-                assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
-
-                if ((*rit)->getPriority() == 0)
+                assert(inputStatesByName_.find((*it)->getName()) != inputStatesByName_.end());
+
+                if ((*it)->getPriority() == 0)
                 {
                     // Get smallest possible priority between 1 and maxStateStackSize_s
-                    for(std::map<int, InputState*>::const_reverse_iterator rit2 = activeStates_.rbegin();
-                        rit2 != activeStates_.rend(); ++rit2)
+                    for(std::map<int, InputState*>::const_reverse_iterator rit = activeStates_.rbegin();
+                        rit != activeStates_.rend(); ++rit)
                     {
-                        if (rit2->first < InputStatePriority::HighPriority)
+                        if (rit->first < InputStatePriority::HighPriority)
                         {
-                            (*rit)->setPriority(rit2->first + 1);
+                            (*it)->setPriority(rit->first + 1);
                             break;
                         }
                     }
                     // In case no normal handler was on the stack
-                    if ((*rit)->getPriority() == 0)
-                        (*rit)->setPriority(1);
+                    if ((*it)->getPriority() == 0)
+                        (*it)->setPriority(1);
                 }
-                activeStates_[(*rit)->getPriority()] = (*rit);
+                activeStates_[(*it)->getPriority()] = (*it);
                 _updateActiveStates();
-                (*rit)->onEnter();
+                (*it)->onEnter();
             }
             stateEnterRequests_.clear();
@@ -797,8 +797,8 @@
         if (!stateDestroyRequests_.empty())
         {
-            for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin();
-                rit != stateDestroyRequests_.rend(); ++rit)
-            {
-                _destroyState((*rit));
+            for (std::set<InputState*>::iterator it = stateDestroyRequests_.begin();
+                it != stateDestroyRequests_.end(); ++it)
+            {
+                _destroyState((*it));
             }
             stateDestroyRequests_.clear();
