fix memory leak for outstanding resource
authorYoung Ik Cho <youngik.cho@samsung.com>
Wed, 8 May 2013 01:52:16 +0000 (10:52 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Wed, 8 May 2013 01:52:16 +0000 (10:52 +0900)
Change-Id: Iaa96fc78c2441d892dc19c98d01d404019de8a97
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
src/app/FAppAppResource.cpp
src/app/FApp_AppRegistryImpl.cpp
src/app/FApp_AppResourceImpl.cpp

index f078e84..3d7474b 100644 (file)
@@ -26,6 +26,9 @@
 #include <FSec_AccessController.h>
 #include "FApp_AppResourceImpl.h"
 #include "FApp_AppInfo.h"
+#ifdef _SINGLETON_CLEANUP
+#include "FApp_LongevityManager.h"
+#endif
 
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
@@ -76,6 +79,10 @@ AppResource::GetInstance(void)
        if (pSelfAppResource == null)
        {
                pSelfAppResource = _AppResourceImpl::GetInstanceN(APP_RESOURCE_DEFAULT);
+
+#ifdef _SINGLETON_CLEANUP
+               _LongevityManager::GetInstance().RegisterOwnership(*pSelfAppResource);
+#endif
        }
 
 //     ClearLastResult();      // as this method does not register any exception.
index 6aa8f58..9d2ab4b 100644 (file)
@@ -43,11 +43,7 @@ _AppRegistryImpl::_AppRegistryImpl(void)
 
 _AppRegistryImpl::~_AppRegistryImpl(void)
 {
-       if (__pRegistry != null)
-       {
-               delete __pRegistry;
-               __pRegistry = null;
-       }
+       delete __pRegistry;
 }
 
 
@@ -62,8 +58,8 @@ _AppRegistryImpl::Construct(void)
        const String& packageId = _AppInfo::GetPackageId();
        String regName = _AppInfo::GetAppRootPath() + L"data/";
 
-       SysAssertf(!packageId.IsEmpty(), "Empty packageId.");
-       r = regName.Append(static_cast <const String&>(packageId));
+       SysAssertf(!packageId.IsEmpty(), "Empty package.");
+       r = regName.Append(packageId);
        SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] String appending has failed.", GetErrorMessage(r));
 
        __pRegistry = new (std::nothrow) Registry();
index fe9c18f..dcb5d99 100644 (file)
@@ -94,7 +94,7 @@ _AppResourceImpl::GetInstanceN(AppResourceBy type, const Tizen::Base::String& va
        r = __pContainer->ContainsKey(value, hasAppResource);
        SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Checking to contain is failed.", GetErrorMessage(r));
 
-       if(hasAppResource == true)
+       if (hasAppResource)
        {
                return static_cast<AppResource*> (__pContainer->GetValue(value));
        }