From 74c0f4f0ba1086bbed06949b2d6958f8270b622d Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Mon, 28 Oct 2013 10:25:00 +0900 Subject: [PATCH] fix memory leak Change-Id: I926e024b168279c0f35939f2c176dd7bf97c6fb9 Signed-off-by: jungmin76.park --- inc/FShell_AppContext.h | 16 +++++++++++++--- src/FShell_AppContext.cpp | 17 +++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/inc/FShell_AppContext.h b/inc/FShell_AppContext.h index dd6b05b..5d50ab3 100644 --- a/inc/FShell_AppContext.h +++ b/inc/FShell_AppContext.h @@ -26,10 +26,11 @@ #include #include +#include +#include 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; diff --git a/src/FShell_AppContext.cpp b/src/FShell_AppContext.cpp index e30e2e0..779b43f 100644 --- a/src/FShell_AppContext.cpp +++ b/src/FShell_AppContext.cpp @@ -23,10 +23,7 @@ #include #include #include -#include -#include #include -#include #include #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."); -- 2.7.4