fix not to delete _AppContext in destructor of AppWidgetManagerService, when the...
authorjungmin76.park <jungmin76.park@samsung.com>
Wed, 30 Oct 2013 08:45:48 +0000 (17:45 +0900)
committerjungmin76.park <jungmin76.park@samsung.com>
Wed, 30 Oct 2013 08:45:48 +0000 (17:45 +0900)
Change-Id: I393b9325e3a5c3d0dea73319ee90945283d75042
Signed-off-by: jungmin76.park <jungmin76.park@samsung.com>
inc/FShell_AppWidgetManagerService.h
src/FShell_AppWidgetManagerService.cpp

index bd7470b..dec320f 100644 (file)
@@ -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<Tizen::Base::String, _AppContext*> __appContextList;
        Tizen::Base::Runtime::Timer __pingTimer;
+
+       enum CoreDaemonConnectionState
+       {
+               NONE = 0,
+               CONNECTED,
+               DISCONNECTED,
+       };
+       static CoreDaemonConnectionState __coreDaemonConnectionState;
 };     // class AppWidgetManagerService
 
 class _AppWidgetHelper
index 36a9940..89a8a62 100644 (file)
@@ -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<String, _AppContext*>* 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,