From: Hwankyu Jhun Date: Fri, 11 Aug 2017 01:54:53 +0000 (+0900) Subject: Add a fallback about updating instance X-Git-Tag: accepted/tizen/3.0/common/20170811.132449^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=1b9774d7a11892bba972697d3cc7f447d97a5efa;p=platform%2Fcore%2Fappfw%2Fappcore-widget.git Add a fallback about updating instance Change-Id: Icc45d5f4fddbadd8deeb81bdd024a47543b2a09c Signed-off-by: Hwankyu Jhun --- diff --git a/src/widget-private.h b/src/widget-private.h index 1c7f519..0813ebc 100644 --- a/src/widget-private.h +++ b/src/widget-private.h @@ -47,6 +47,7 @@ struct _widget_context { guint periodic_timer; bool pending_update; widget_instance_lifecycle_callback_s ops; + char *pending_content; }; typedef struct _widget_context widget_context_s; diff --git a/src/widget_app.c b/src/widget_app.c index 858e7fc..50712c8 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -324,10 +324,11 @@ static int __instance_resume(widget_class_h handle, const char *id, int send_upd return 0; /* LCOV_EXCL_LINE */ } + wc->state = WC_RUNNING; if (wc->pending_update) { _D("pending update!"); wc->pending_update = false; - __instance_update(wc->provider, wc->id, 0, NULL); + __instance_update(wc->provider, wc->id, 0, wc->pending_content); if (wc->period > 0) { _D("Restart timer!"); @@ -339,7 +340,6 @@ static int __instance_resume(widget_class_h handle, const char *id, int send_upd if (handle->ops.resume) handle->ops.resume(wc, handle->user_data); - wc->state = WC_RUNNING; _D("%s is resumed", id); if (send_update) { ret = __send_update_status(handle->classid, wc->id, @@ -425,6 +425,20 @@ static int __instance_resize(widget_class_h handle, const char *id, int w, int h return ret; } +static void __update_pending_content(widget_context_s *wc, const char *content) +{ + if (wc->pending_content) { + free(wc->pending_content); + wc->pending_content = NULL; + } + + if (content) { + wc->pending_content = strdup(content); + if (wc->pending_content == NULL) + _W("Out of memory"); + } +} + /* LCOV_EXCL_START */ static int __instance_update_all(widget_class_h handle, int force, const char *content) { @@ -439,11 +453,17 @@ static int __instance_update_all(widget_class_h handle, int force, const char *c if (handle->ops.update) { while (context) { wc = (widget_context_s *)context->data; + context = context->next; + if (wc->state != WC_RUNNING && !force) { + __update_pending_content(wc, content); + wc->pending_update = true; + continue; + } + handle->ops.update(wc, b, force, handle->user_data); ret = __send_update_status(handle->classid, wc->id, WIDGET_INSTANCE_EVENT_UPDATE, NULL); _D("updated:%s", wc->id); - context = context->next; } } @@ -465,6 +485,12 @@ static int __instance_update(widget_class_h handle, const char *id, int force, c return -1; } + if (wc->state != WC_RUNNING && !force) { + __update_pending_content(wc, content); + wc->pending_update = true; + return 0; + } + if (content) b = bundle_decode((const bundle_raw *)content, strlen(content)); @@ -593,6 +619,9 @@ static int __instance_destroy(widget_class_h handle, const char *id, if (wc->periodic_timer) g_source_remove(wc->periodic_timer); + if (wc->pending_content) + free(wc->pending_content); + free(wc); if (_widget_app_get_contexts() == NULL && !exit_called) /* all instance destroyed */