dmuratshin 9 years ago
parent
commit
5eacc1655e
3 changed files with 17 additions and 2 deletions
  1. 6 2
      src/flow/Scene.cpp
  2. 10 0
      src/flow/flow.cpp
  3. 1 0
      src/flow/flow.h

+ 6 - 2
src/flow/Scene.cpp

@@ -198,9 +198,9 @@ namespace oxygine
         void Scene::postShowing()
         {
             LOGD("%-20s '%s'", "Scene.postShowing", getName().c_str());
-            Event ev(EVENT_POST_SHOWING);
-            dispatchEvent(&ev);
             _inloop = true;
+            Event ev(EVENT_POST_SHOWING);
+            dispatchEvent(&ev);            
         }
 
         void Scene::preHiding()
@@ -247,6 +247,10 @@ namespace oxygine
             _remove = true;
             _resultCB = resultCallback();
             OX_ASSERT(_dialog == false);
+            if (!_holder->getParent())
+            {
+                flow::get().removeFromStack(this);
+            }
         }
     }
 }

+ 10 - 0
src/flow/flow.cpp

@@ -120,6 +120,16 @@ namespace oxygine
             return std::find(scenes.begin(), scenes.end(), scene) != scenes.end();
         }
 
+        void Flow::removeFromStack(spScene scene)
+        {
+            OX_ASSERT(scene->_inloop == false);
+            auto it = std::find(scenes.begin(), scenes.end(), scene);
+            if (it != scenes.end())
+            {
+                scenes.erase(it);
+            }
+        }
+
         void Flow::phaseBegin(spScene current, spScene next, bool back)
         {
             _back = back;

+ 1 - 0
src/flow/flow.h

@@ -55,6 +55,7 @@ namespace oxygine
             void blockedTouch(Event*);
 
             bool hasSceneInStack(spScene) const;
+            void removeFromStack(spScene);
 
             std::vector<spScene> scenes;
             std::vector<spScene> scenes2show;