fix memory leak
authorjungmin76.park <jungmin76.park@samsung.com>
Mon, 28 Oct 2013 01:25:00 +0000 (10:25 +0900)
committerjungmin76.park <jungmin76.park@samsung.com>
Mon, 28 Oct 2013 05:18:21 +0000 (14:18 +0900)
Change-Id: I926e024b168279c0f35939f2c176dd7bf97c6fb9
Signed-off-by: jungmin76.park <jungmin76.park@samsung.com>
inc/FShell_AppContext.h
src/FShell_AppContext.cpp

index dd6b05b..5d50ab3 100644 (file)
 
 #include <FAppTypes.h>
 #include <FBaseColArrayListT.h>
+#include <FBaseColHashMap.h>
+#include <FBaseColHashMapT.h>
 
 namespace Tizen { namespace Base  { namespace Collection
 {
-class HashMap;
 class IList;
 }}}
 
@@ -103,10 +104,19 @@ private:
        struct PendingEvent
        {
                PendingEvent(const Tizen::Base::String& operation, Tizen::Base::Collection::HashMap* pHashMap)
-                : operation(operation), pArg(pHashMap) {  }
+                : operation(operation), pArgs(pHashMap) {  }
+
+               ~PendingEvent(void)
+               {
+                       if (pArgs)
+                       {
+                               pArgs->RemoveAll(true);
+                               delete pArgs;
+                       }
+               }
 
                Tizen::Base::String operation;
-               Tizen::Base::Collection::HashMap* pArg;
+               Tizen::Base::Collection::HashMap* pArgs;
        };
 
        const Tizen::App::AppId __appId;
index e30e2e0..779b43f 100644 (file)
 #include <unique_ptr.h>
 #include <FBase.h>
 #include <FBaseSysLog.h>
-#include <FBaseColHashMap.h>
-#include <FBaseColIMapEnumeratorT.h>
 #include <FAppApp.h>
-#include <FBaseComparerT.h>
 #include <FApp_AppManagerImpl.h>
 #include "FShell_AppWidgetContext.h"
 #include "FShell_AppWidgetContextHelper.h"
@@ -255,7 +252,10 @@ _AppContext::SendRequestToApp(const AppId& providerAppId, const String& operatio
        if (GetConnectionState() == CONNECTION_STATE_NONE || GetConnectionState() == CONNECTION_STATE_DISCONNECTED)
        {
                SysLog(NID_SHELL, "The application is not running.");
-               result r = _AppWidgetRequestHelper::SendAppControlRequest(providerAppId, operation, pArgs);
+               r = _AppWidgetRequestHelper::SendAppControlRequest(providerAppId, operation, pArgs);
+               pArgs->RemoveAll(true);
+               delete pArgs;
+
                SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] Failed to SendRequestToApp", GetErrorMessage(r));
 
                SetWaitingStatus(true);
@@ -265,16 +265,17 @@ _AppContext::SendRequestToApp(const AppId& providerAppId, const String& operatio
        {
                if (GetConnectionState() == CONNECTION_STATE_CONNECTING || GetWaitingStatus() == true)
                {
-                       SysLog(NID_SHELL, "The application is running but IPC is not connected yet.");
+                       SysLog(NID_SHELL, "The application is running but IPC is not connected yet. Queueing the request (%ls).", operation.GetPointer() );
                        __pPendingEventList->Add(new (nothrow) PendingEvent(operation, pArgs));
                }
                else
                {
                        SysLog(NID_SHELL, "The application is running and IPC is connected.");
                        r  = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), operation, pArgs);
-
                        pArgs->RemoveAll(true);
                        delete pArgs;
+                       SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] Failed to SendRequestToApp", GetErrorMessage(r));
+
                        SetWaitingStatus(true);
                }
        }
@@ -286,14 +287,14 @@ result
 _AppContext::SendPendingEvent(void)
 {
        SetWaitingStatus(false);
-       TryReturn(__pPendingEventList->GetCount() > 0, E_DATA_NOT_FOUND, "This context has no pending event. Please find next pending event context.");
+       TryReturn(__pPendingEventList->GetCount() > 0, E_DATA_NOT_FOUND, "No pending event.");
 
        PendingEvent* pEvent = null;
        __pPendingEventList->GetAt(0, pEvent);
        __pPendingEventList->RemoveAt(0);
        SysLog(NID_SHELL, "(%d) Remains in __pPendingEventList.", __pPendingEventList->GetCount());
 
-       result r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pEvent->operation, pEvent->pArg);
+       result r = _AppWidgetRequestHelper::SendIpcRequest(GetClientId(), pEvent->operation, pEvent->pArgs);
        delete pEvent;
        SysTryReturnResult(NID_SHELL, !IsFailed(r), E_SYSTEM, "SendIpcRequest failed.");