Enhace scene transition logic for safe destroy of pending one.
authorSeungWon Lee <lsw2000.lee@samsung.com>
Sat, 13 Jul 2013 12:23:43 +0000 (21:23 +0900)
committerSeungWon Lee <lsw2000.lee@samsung.com>
Sat, 13 Jul 2013 12:23:43 +0000 (21:23 +0900)
Change-Id: I0072c84a6af8d8629ac5a08c0fba9909d7e72711
Signed-off-by: SeungWon Lee <lsw2000.lee@samsung.com>
src/ui/scenes/FUiScenes_SceneManagerImpl.cpp
src/ui/scenes/FUiScenes_SceneManagerImpl.h

index 016c4e1..8ac9efb 100644 (file)
@@ -108,6 +108,7 @@ _SceneManagerImpl::_SceneManagerImpl(void)
        , __correspondFrameControlHandle()
        , __sceneTransitionProgressing(false)
        , __pDisabledForm(null)
+       , __destroyPendingScene(L"")
 {
        for (int i = 0; i < FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_MAX; i++)
        {
@@ -960,7 +961,19 @@ _SceneManagerImpl::OnSceneControlEventReceived(_SceneControlEventArg::SceneContr
        switch (eventType)
        {
        case _SceneControlEventArg::SCENE_CONTROL_EVENT_TYPE_DESTROY:
-               DestroyScene(sceneId);
+               if (!__destroyPendingScene.IsEmpty())
+               {
+                       SysTryLog(NID_UI_SCENES, __destroyPendingScene == sceneId, "Abnormal! __destroyPendingScene != sceneId");
+                       DestroyScene(sceneId);
+                       if (__destroyPendingScene == sceneId)
+                       {
+                               __destroyPendingScene.Clear();
+                       }
+               }
+               else
+               {
+                       SysSecureLog(NID_UI_SCENES, "The Scene was already destroyed on the GotoScene.");
+               }
                break;
 
        default:
@@ -1034,6 +1047,19 @@ _SceneManagerImpl::GotoScene(bool forward, const SceneId& sceneId, SceneTransiti
 
        // 2. Find the Scene on SceneContainer - Scene and correspond UI control has same life time.
        pScene = GetSceneFromContainer(sceneId);
+
+       // If the destination Scene is pending to destroy then destroy and invalidate the pScene
+       if (pScene && !__destroyPendingScene.IsEmpty())
+       {
+               if (sceneId == __destroyPendingScene)
+               {
+                       __destroyPendingScene.Clear();
+                       DestroyScene(sceneId);
+                       pScene = null;
+                       SysLog(NID_UI_SCENES, "DestroySceneAsync not finished, Do force destroy.");
+               }
+       }
+
        if (pScene) // Activate pScene: Scene already existing then Re-activate associated a Form and a Panel.
        {
                sceneAlreadyCreated = true;
@@ -1696,6 +1722,7 @@ _SceneManagerImpl::DestroySceneAsync(const SceneId& sceneId)
        SysTryReturnVoidResult(NID_UI_SCENES, pArg != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.",
                                                   GetErrorMessage(E_OUT_OF_MEMORY));
        __sceneControlEvent.FireAsync(*pArg);
+       __destroyPendingScene = sceneId;
 }
 
 void
index d5a4ca6..e8b7ffb 100644 (file)
@@ -211,6 +211,7 @@ private:
        bool __sceneTransitionProgressing;
        Tizen::Base::Runtime::Mutex __sceneTransitionMutex;
        Tizen::Ui::Controls::Form* __pDisabledForm;
+       SceneId __destroyPendingScene;
 
 }; // _SceneManagerImpl
 } } } // Tizen::Ui::Scenes