PUI: fix frame_cb and pui_ani_control not to make irregular timer callback call
[platform/core/uifw/libpui.git] / src / PUI_ani.c
index e733987..28db340 100644 (file)
@@ -124,6 +124,7 @@ static Eina_Bool
 _pui_ani_frame_cb(void *data)
 {
        Eina_Bool ret;
+       Ecore_Timer *timer = NULL;
 
        pui_ani_t *ani = (pui_ani_t *)data;
 
@@ -161,7 +162,20 @@ _pui_ani_frame_cb(void *data)
        if (ret && PUI_ANI_STATUS_STARTED == ani->status)
                pui_ani_status_update(ani, PUI_ANI_STATUS_RUNNING);
 
-       return EINA_TRUE;
+       ecore_timer_del(ani->frame_cb_timer);
+       ani->frame_cb_timer = NULL;
+
+       timer = ecore_timer_add(ani->frame_interval, _pui_ani_frame_cb, ani);
+
+       if (!timer)
+       {
+               pui_err("Failed to add ecore timer !\n");
+               return 0;
+       }
+
+       ani->frame_cb_timer = timer;
+
+       return EINA_FALSE;
 }
 
 pui_bool
@@ -423,6 +437,9 @@ _pui_ani_control_with_force(pui_ani_h ani_h, pui_ani_cmd cmd, int repeat, pui_bo
        {
                ei = ani_func->ani_stop(ani, force);
 
+               if (ani->frame_cb_timer)
+                       pui_ani_remove_frame_cb(ani);
+
                if (ei != PUI_INT_ERROR_NONE)
                {
                        pui_err("Failied on stopping animation ! (id:%s)\n", ani->id);
@@ -430,9 +447,6 @@ _pui_ani_control_with_force(pui_ani_h ani_h, pui_ani_cmd cmd, int repeat, pui_bo
                        if (ani->status != PUI_ANI_STATUS_STOPPED)
                                pui_ani_status_update(ani, PUI_ANI_STATUS_STOPPED);
 
-                       if (ani->frame_cb_timer)
-                               pui_ani_remove_frame_cb(ani);
-
                        return PUI_ERROR_INTERNAL;
                }