Fix error log
[platform/core/appfw/appcore-widget.git] / src / base / widget_base.c
index c443d00..678b6f9 100644 (file)
@@ -302,11 +302,12 @@ static void __control_create(const char *class_id, const char *id, bundle *b)
 
        /* call stub create */
        appcore_multiwindow_base_instance_run(class_id, id, data);
-       data->args = NULL;
-       bundle_get_str(b, WIDGET_K_CONTENT_INFO, &content);
-       if (content)
-               data->content = strdup(content);
-
+       if (appcore_multiwindow_base_instance_find(id)) {
+               data->args = NULL;
+               bundle_get_str(b, WIDGET_K_CONTENT_INFO, &content);
+               if (content)
+                       data->content = strdup(content);
+       }
 }
 
 static void __control_resume(const char *class_id, const char *id, bundle *b)
@@ -524,6 +525,8 @@ static void __control_destroy(const char *class_id, const char *id, bundle *b)
        free(data->id);
        free(data);
        __check_empty_instance();
+       aul_widget_write_log(LOG_TAG,
+               "[%s:%d] instance_id(%s)", __FUNCTION__, __LINE__, id);
 }
 
 static void __control_change_period(const char *class_id, const char *id,
@@ -638,6 +641,7 @@ static int __multiwindow_control(bundle *b, void *data)
                return 0;
        }
 
+       LOGI("app control operation(%s)", operation);
        if (strcmp(operation, "create") == 0)
                __control_create(class_id, id, b);
        else if (strcmp(operation, "resize") == 0)
@@ -757,14 +761,17 @@ static void __multiwindow_trim_memory(void *data)
 
 EXPORT_API int widget_base_exit(void)
 {
-       int ret;
+       int ret = 0;
+       int cnt;
 
        appcore_multiwindow_base_exit();
-       if (appcore_multiwindow_base_instance_get_cnt() == 0 && __is_permanent) {
+       cnt = appcore_multiwindow_base_instance_get_cnt();
+       if (cnt == 0 && __is_permanent)
                ret = aul_notify_exit();
-               aul_widget_write_log(LOG_TAG, "[%s:%d] permanent exit : %d",
-                       __FUNCTION__, __LINE__, ret);
-       }
+
+       aul_widget_write_log(LOG_TAG,
+               "[%s:%d] exit : ret(%d), cnt(%d), permanent(%d)",
+                       __FUNCTION__, __LINE__, ret, cnt, __is_permanent);
 
        return 0;
 }
@@ -1385,13 +1392,12 @@ static void __multiwindow_instance_create(
                __instance_drop(instance_h);
        } else {
                LOGD("%s is created", id);
+               aul_widget_instance_add(class_id, id);
                ret = __send_update_status(class_id, id,
                        WIDGET_INSTANCE_EVENT_CREATE, 0, NULL);
                if (ret < 0)
                        LOGE("Fail to send create status (%d) ", ret);
 
-               aul_widget_instance_add(class_id, id);
-
                ret = bundle_get_byte(b, WIDGET_K_PERIOD, (void **)&period,
                                &size);
                if (ret == BUNDLE_ERROR_NONE && *period > 0) {
@@ -1617,7 +1623,7 @@ EXPORT_API widget_base_class *widget_base_class_add(widget_base_class cls,
        }
 
        if (!class_id) {
-               LOGE("class is is NULL");
+               LOGE("class id is NULL");
                set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
                return NULL;
        }