Implement widget_service_get_instance_count
[platform/core/appfw/appcore-widget.git] / src / widget_app.c
index 2128f0b..60d3d08 100755 (executable)
@@ -441,10 +441,10 @@ static int __instance_destroy(widget_class_h handle, const char *id,
        int event = WIDGET_INSTANCE_EVENT_TERMINATE;
        bundle *content_info;
 
-
        if (!wc) {
-               _E("could not find widget obj: %s", id); /* LCOV_EXCL_LINE */
-               return WIDGET_ERROR_INVALID_PARAMETER; /* LCOV_EXCL_LINE */
+               _E("could not find widget obj: %s, clear amd info", id);        /* LCOV_EXCL_LINE */
+               aul_widget_instance_del(handle->classid, id);                   /* LCOV_EXCL_LINE */
+               return WIDGET_ERROR_NONE;                                       /* LCOV_EXCL_LINE */
        }
 
        wc->state = WC_TERMINATED;
@@ -458,13 +458,12 @@ static int __instance_destroy(widget_class_h handle, const char *id,
 
        if (reason == WIDGET_APP_DESTROY_TYPE_PERMANENT) {
                event = WIDGET_INSTANCE_EVENT_DESTROY;
+               aul_widget_instance_del(handle->classid, id);
        } else {
                ret = __send_update_status(handle->classid, id,
                                WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info);
        }
 
-       aul_widget_instance_del(handle->classid, id);
-
        if (content_info)
                bundle_free(content_info);
 
@@ -614,6 +613,7 @@ static void __pause_all(int send_update)
                        __instance_pause(cxt->provider, cxt->id, send_update);
                        break;
                }
+               LOGD("pause %s", cxt->id);
                iter = g_list_next(iter);
        }
 }
@@ -646,16 +646,15 @@ static void __destroy_all(int reason, int send_update)
        GList *iter = g_list_first(contexts);
 
        __pause_all(send_update);
-
        while (iter != NULL) {
                widget_context_s *cxt = (widget_context_s *)iter->data;
-
+               iter = g_list_next(iter);
                switch (cxt->state) {
                case WC_PAUSED:
+                       LOGD("destroy %s", cxt->state, cxt->id);
                        __instance_destroy(cxt->provider, cxt->id, reason, send_update);
                        break;
                }
-               iter = g_list_next(iter);
        }
 }