Add a fallback about updating instance 33/150833/3
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 11 Aug 2017 01:54:53 +0000 (10:54 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Thu, 21 Sep 2017 08:38:25 +0000 (17:38 +0900)
Change-Id: Icc45d5f4fddbadd8deeb81bdd024a47543b2a09c
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
src/base/widget_base.c

index 0cf602c..34c94f5 100644 (file)
@@ -90,6 +90,7 @@ typedef struct _widget_base_instance_data {
        double period;
        guint periodic_timer;
        bool pending_update;
+       char *pending_content;
        void *user_data;
 } widget_base_instance_data;
 
@@ -181,6 +182,7 @@ static void __instance_drop(appcore_multiwindow_base_instance_h instance_h)
 
        data = appcore_multiwindow_base_instance_get_extra(instance_h);
        appcore_multiwindow_base_instance_drop(instance_h);
+       free(data->pending_content);
        free(data->content);
        free(data->id);
        free(data);
@@ -444,6 +446,29 @@ static void __call_update_cb(const char *class_id, const char *id, int force,
                bundle_free(content);
 }
 
+static void __update_pending_content(
+               appcore_multiwindow_base_instance_h instance_h,
+               const char *content_raw)
+{
+       widget_base_instance_data *data;
+
+       data = (widget_base_instance_data *)
+                       appcore_multiwindow_base_instance_get_extra(instance_h);
+
+       if (data->pending_content) {
+               free(data->pending_content);
+               data->pending_content = NULL;
+       }
+
+       if (content_raw) {
+               data->pending_content = strdup(content_raw);
+               if (data->pending_content == NULL)
+                       LOGW("Out of memory");
+       }
+
+       data->pending_update = true;
+}
+
 static void __update_process(const char *class_id, const char *id,
                appcore_multiwindow_base_instance_h instance_h, void *data)
 {
@@ -465,7 +490,10 @@ static void __update_process(const char *class_id, const char *id,
                force = 0;
 
        bundle_get_str(b, WIDGET_K_CONTENT_INFO, &content_raw);
-       __call_update_cb(class_id, id, force, content_raw);
+       if (!appcore_multiwindow_base_instance_is_resumed(instance_h) && !force)
+               __update_pending_content(instance_h, content_raw);
+       else
+               __call_update_cb(class_id, id, force, content_raw);
 }
 
 static void __control_update(const char *class_id, const char *id, bundle *b)
@@ -505,6 +533,7 @@ static void __control_destroy(const char *class_id, const char *id, bundle *b)
 
        /* call stub terminate */
        appcore_multiwindow_base_instance_exit(instance_h);
+       free(data->pending_content);
        free(data->content);
        free(data->id);
        free(data);
@@ -1383,7 +1412,7 @@ static void __multiwindow_instance_resume(
        if (data->pending_update) {
                LOGD("pending update!");
                data->pending_update = false;
-               __control_update(class_id, data->id, data->args);
+               __call_update_cb(class_id, data->id, 0, data->pending_content);
                if (data->period > 0) {
                        LOGD("Restart timer!");
                        data->periodic_timer = g_timeout_add_seconds(