Fix memory leak issue. (Checked with valgrind)
authorSeungWon Lee <lsw2000.lee@samsung.com>
Thu, 18 Apr 2013 10:52:42 +0000 (19:52 +0900)
committerGerrit Code Review <gerrit2@kim11>
Thu, 18 Apr 2013 10:58:10 +0000 (19:58 +0900)
Change-Id: Ie658b6fcc8591c79eba0b3af2d0afc4f951146d9
Signed-off-by: SeungWon Lee <lsw2000.lee@samsung.com>
src/ui/scenes/FUiScenes_SceneManagerImpl.cpp

index bfbbe07..b1b028f 100644 (file)
@@ -121,6 +121,8 @@ _SceneManagerImpl::_SceneManagerImpl(void)
 
 _SceneManagerImpl::~_SceneManagerImpl(void)
 {
+       bool memoryError = false;
+
        std::unique_ptr<IMapEnumeratorT<String, _SceneDescription*> > pMapEnum(__sceneMap.GetMapEnumeratorN());
        if (pMapEnum)
        {
@@ -133,7 +135,7 @@ _SceneManagerImpl::~_SceneManagerImpl(void)
        }
        else
        {
-               SysLogException(NID_UI_SCENES, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+               memoryError = true;
        }
 
        std::unique_ptr<IMapEnumeratorT<String, SceneTransition*> > pTransitionMapEnum(__transitionMap.GetMapEnumeratorN());
@@ -148,6 +150,26 @@ _SceneManagerImpl::~_SceneManagerImpl(void)
        }
        else
        {
+               memoryError = true;
+       }
+
+       std::unique_ptr<IMapEnumeratorT<SceneId, Scene*> > pSceneContainerEnum(__sceneContainer.GetMapEnumeratorN());
+       if (pSceneContainerEnum)
+       {
+               while (pSceneContainerEnum->MoveNext() == E_SUCCESS)
+               {
+                       Scene* pValue = null;
+                       pSceneContainerEnum->GetValue(pValue);
+                       delete pValue;
+               }
+       }
+       else
+       {
+               memoryError = true;
+       }
+
+       if (memoryError)
+       {
                SysLogException(NID_UI_SCENES, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
        }
 }