Send create aborted event to the widget viewer
[platform/core/appfw/appcore-widget.git] / src / widget_app.c
index 3911a6d..e25fdd1 100755 (executable)
@@ -455,8 +455,10 @@ static int __instance_create(widget_class_h handle, const char *id, const char *
        bundle *content_info = NULL;
 
        wc = (widget_context_s *)calloc(1, sizeof(widget_context_s));
-       if (!wc)
+       if (!wc) {
+               _E("Out of memory");
                return WIDGET_ERROR_OUT_OF_MEMORY;
+       }
 
        wc->state = WC_READY;
        wc->id = strdup(id);
@@ -473,7 +475,18 @@ static int __instance_create(widget_class_h handle, const char *id, const char *
 
        ret = handle->ops.create(wc, content_info, w, h, handle->user_data);
        if (ret < 0) {
-               /* TODO send abort */
+               _W("Create callback resturns error(%d)", ret);
+               ret = __send_update_status(handle->classid, wc->id,
+                               WIDGET_INSTANCE_EVENT_CREATE_ABORTED, NULL);
+               _widget_app_remove_context(wc);
+               if (wc->id)
+                       free(wc->id);
+               if (wc->content)
+                       free(wc->content);
+               free(wc);
+
+               if (_widget_app_get_contexts() == NULL && !exit_called)
+                       widget_app_exit();
        } else {
                ret = __send_update_status(handle->classid, wc->id,
                        WIDGET_INSTANCE_EVENT_CREATE, NULL);