Resolved memory leak in DateTimeBar
authorBhavya Kumili <bhavya.k@samsung.com>
Wed, 10 Jul 2013 05:59:51 +0000 (11:29 +0530)
committerBhavya Kumili <bhavya.k@samsung.com>
Wed, 10 Jul 2013 08:10:27 +0000 (13:40 +0530)
Change-Id: I1ce5066d68f977ba01e2eac567325c785af02a01

src/ui/controls/FUiCtrl_DateTimeBar.cpp

index 34ecacd..b4daa2c 100644 (file)
@@ -865,14 +865,7 @@ _DateTimeBar::CreateAnimationN(VisualElement& source, bool open)
 
        VisualElementPropertyAnimation* pOpacityAnimation = null;
        VisualElementPropertyAnimation* pBoundsAnimation = null;
-       String* pOpenUserData = null;
-       String* pCloseUserData = null;
-
-       pOpenUserData = new (std::nothrow) String(L"BarOpenAnimation");
-       SysTryCatch(NID_UI_CTRL, pOpenUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
-
-       pCloseUserData = new (std::nothrow) String(L"BarCloseAnimation");
-       SysTryCatch(NID_UI_CTRL, pCloseUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation is failed");
+       String* pUserData = null;
 
        pAnimationGroup->SetDuration(ANIMATION_DURATION);
 
@@ -881,13 +874,19 @@ _DateTimeBar::CreateAnimationN(VisualElement& source, bool open)
 
        pOpacityAnimation->SetPropertyName("opacity");
 
-       if (open == true)
+       if (open)
        {
+               pUserData = new (std::nothrow) String(L"BarOpenAnimation");
+               SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
                pOpacityAnimation->SetStartValue(Variant(0.0f));
                pOpacityAnimation->SetEndValue(Variant(1.0f));
        }
        else
        {
+               pUserData = new (std::nothrow) String(L"BarCloseAnimation");
+               SysTryCatch(NID_UI_CTRL, pUserData, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+
                pOpacityAnimation->SetStartValue(Variant(1.0f));
                pOpacityAnimation->SetEndValue(Variant(0.0f));
        }
@@ -906,13 +905,13 @@ _DateTimeBar::CreateAnimationN(VisualElement& source, bool open)
        {
                pBoundsAnimation->SetStartValue(Variant(FloatPoint(startValue.x, startValue.y)));
                pBoundsAnimation->SetEndValue(Variant(FloatPoint(source.GetBounds().x, source.GetBounds().y)));
-               pBoundsAnimation->SetUserData((void*)(pOpenUserData));
+               pBoundsAnimation->SetUserData((void*)(pUserData));
        }
        else
        {
                pBoundsAnimation->SetStartValue(Variant(FloatPoint(source.GetBounds().x, source.GetBounds().y)));
                pBoundsAnimation->SetEndValue(Variant(FloatPoint(startValue.x, startValue.y)));
-               pBoundsAnimation->SetUserData((void*)(pCloseUserData));
+               pBoundsAnimation->SetUserData((void*)(pUserData));
        }
        pBoundsAnimation->SetDuration(ANIMATION_DURATION);
        pBoundsAnimation->SetVisualElementAnimationStatusEventListener(this);
@@ -924,8 +923,8 @@ _DateTimeBar::CreateAnimationN(VisualElement& source, bool open)
 
 CATCH:
        delete pAnimationGroup;
-       delete pOpenUserData;
-       delete pCloseUserData;
+       delete pOpacityAnimation;
+       delete pUserData;
        return null;
 }