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!");
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,
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)
{
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;
}
}
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));
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 */