From 2eee9bb4182f9393c2b19f60ed238af44059405f Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Wed, 30 Oct 2013 17:45:48 +0900 Subject: [PATCH] fix not to delete _AppContext in destructor of AppWidgetManagerService, when the data-provider-master is already terminated to avoid double free(XFreeGC) Change-Id: I393b9325e3a5c3d0dea73319ee90945283d75042 Signed-off-by: jungmin76.park --- inc/FShell_AppWidgetManagerService.h | 12 ++++++++++-- src/FShell_AppWidgetManagerService.cpp | 16 +++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/inc/FShell_AppWidgetManagerService.h b/inc/FShell_AppWidgetManagerService.h index bd7470b..dec320f 100644 --- a/inc/FShell_AppWidgetManagerService.h +++ b/inc/FShell_AppWidgetManagerService.h @@ -67,8 +67,8 @@ private: result DeinitializeCoreDaemonEventReceiver(void); // core daemon callbacks - static int OnAppWidgetServiceConnected(struct event_arg *arg, void* data); - static int OnAppWidgetServiceDisconnected(struct event_arg *arg, void* data); + static int OnCoreDaemonConnected(struct event_arg *arg, void* data); + static int OnCoreDaemonDisconnected(struct event_arg *arg, void* data); static int OnAppWidgetCreate(struct event_arg *arg, int *width, int *height, double *priority, void* data); static int OnAppWidgetDestroy(struct event_arg *arg, void* data); static int OnAppWidgetUpdate(struct event_arg *arg, void* data); @@ -127,6 +127,14 @@ private: static AppWidgetManagerService* __pTheInstance; Tizen::Base::Collection::HashMapT __appContextList; Tizen::Base::Runtime::Timer __pingTimer; + + enum CoreDaemonConnectionState + { + NONE = 0, + CONNECTED, + DISCONNECTED, + }; + static CoreDaemonConnectionState __coreDaemonConnectionState; }; // class AppWidgetManagerService class _AppWidgetHelper diff --git a/src/FShell_AppWidgetManagerService.cpp b/src/FShell_AppWidgetManagerService.cpp index 36a9940..89a8a62 100644 --- a/src/FShell_AppWidgetManagerService.cpp +++ b/src/FShell_AppWidgetManagerService.cpp @@ -59,6 +59,7 @@ static const int TIMER_DURATION_PING = 120000; } AppWidgetManagerService* AppWidgetManagerService::__pTheInstance = null; +AppWidgetManagerService::CoreDaemonConnectionState AppWidgetManagerService::__coreDaemonConnectionState = NONE; AppWidgetManagerService::AppWidgetManagerService(void) { @@ -71,10 +72,11 @@ AppWidgetManagerService::~AppWidgetManagerService(void) __pingTimer.Cancel(); - DeinitializeCoreDaemonEventReceiver(); _AppManagerImpl::GetInstance()->RemoveAppEventListener(*this); _SettingInfoImpl::RemoveSettingEventListener(*this); + SysTryReturnVoidResult(NID_SHELL, __coreDaemonConnectionState == CONNECTED, E_SERVICE_DEACTIVATED, "Core daemon is already terminated."); + IMapEnumeratorT* pMapEnum = __appContextList.GetMapEnumeratorN(); if (pMapEnum != null) { @@ -88,6 +90,8 @@ AppWidgetManagerService::~AppWidgetManagerService(void) delete pMapEnum; } + DeinitializeCoreDaemonEventReceiver(); + SysLog(NID_SHELL, "Exit"); } @@ -185,7 +189,7 @@ AppWidgetManagerService::SetSettingEventListener(Tizen::System::ISettingEventLis } int -AppWidgetManagerService::OnAppWidgetServiceConnected(struct event_arg *arg, void* data) +AppWidgetManagerService::OnCoreDaemonConnected(struct event_arg *arg, void* data) { int ret; ret = provider_send_hello(); @@ -193,6 +197,7 @@ AppWidgetManagerService::OnAppWidgetServiceConnected(struct event_arg *arg, void { SysLog(NID_SHELL, "Success to be connected with master daemon"); AppWidgetManagerService::GetInstance()->StartPingTimer(); + __coreDaemonConnectionState = CONNECTED; } else @@ -203,9 +208,10 @@ AppWidgetManagerService::OnAppWidgetServiceConnected(struct event_arg *arg, void } int -AppWidgetManagerService::OnAppWidgetServiceDisconnected(struct event_arg *arg, void* data) +AppWidgetManagerService::OnCoreDaemonDisconnected(struct event_arg *arg, void* data) { SysLog(NID_SHELL, "Disconnected with master daemon"); + __coreDaemonConnectionState = DISCONNECTED; return 0; } @@ -580,8 +586,8 @@ AppWidgetManagerService::InitializeCoreDaemonEventReceiver(const char *pCoreDaem struct event_handler cbs; memset(&cbs, 0, sizeof(event_handler)); - cbs.connected = OnAppWidgetServiceConnected, - cbs.disconnected = OnAppWidgetServiceDisconnected, + cbs.connected = OnCoreDaemonConnected, + cbs.disconnected = OnCoreDaemonDisconnected, cbs.pause = OnAppWidgetBackgroundAll, cbs.resume = OnAppWidgetForegroundAll, cbs.lb_pause = OnAppWidgetBackground, -- 2.7.4