hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=80b59d3b15e553414ab9efe2d9318c043aaa67f4

commit 80b59d3b15e553414ab9efe2d9318c043aaa67f4
Author: Kateryna Fesyna <[email protected]>
Date:   Mon Aug 11 17:32:08 2014 +0900

    EDJ Viewer: fix reseting of layout on edc compiling
    
    Summary:
    This commit changes the signal that is used to initiate the reset of edj 
layout:
    using of EIO_MONITOR_FILE_MODIFIED sometimes causes calling of 
edje_object_file_set() earlier than EDC-file compilation is finished.
    So, using of ECORE_EXE_EVENT_DEL to track the end of compilation helps to 
avoid this problem.
    
    Reviewers: Hermet
    
    Reviewed By: Hermet
    
    Projects: #enventor
    
    Differential Revision: https://phab.enlightenment.org/D1306
---
 src/bin/edj_viewer.c | 41 +++++++++++++++++++++++++++++++++--------
 src/bin/main.c       |  1 -
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/src/bin/edj_viewer.c b/src/bin/edj_viewer.c
index 3ff9fd7..c2b215f 100644
--- a/src/bin/edj_viewer.c
+++ b/src/bin/edj_viewer.c
@@ -22,11 +22,13 @@ struct viewer_s
    Ecore_Timer *timer;
    Eio_Monitor *edj_monitor;
    Ecore_Event_Handler *monitor_event;
+   Ecore_Event_Handler *exe_del_event;
 
    void (*del_cb)(void *data);
    void *data;
 
    Eina_Bool dummy_on;
+   Eina_Bool edj_reload_need : 1;
 };
 
 static void
@@ -137,31 +139,46 @@ view_scroller_create(Evas_Object *parent)
 }
 
 static Eina_Bool
-edj_changed_cb(void *data, int type EINA_UNUSED, void *event)
+exe_del_event_cb(void *data, int type EINA_UNUSED, void *event)
 {
    view_data *vd = data;
    Eio_Monitor_Event *ev = event;
 
-   if (vd->edj_monitor != ev->monitor) return ECORE_CALLBACK_PASS_ON;
-
-   eio_monitor_del(vd->edj_monitor);
+   if (!vd->edj_reload_need) return ECORE_CALLBACK_PASS_ON;
 
    if (!edje_object_file_set(vd->layout, config_edj_path_get(),
-                        vd->group_name))
+                             vd->group_name))
      {
         vd->del_cb(vd->data);
         view_term(vd);
         EINA_LOG_ERR("Failed to load edj file \"%s\"", config_edj_path_get());
+        vd->edj_reload_need = EINA_FALSE;
         return ECORE_CALLBACK_DONE;
      }
 
-   vd->edj_monitor = eio_monitor_add(config_edj_path_get());
-   if (!vd->edj_monitor) EINA_LOG_ERR("Failed to add Eio_Monitor");
-
    view_obj_min_update(vd->layout);
    view_part_highlight_set(vd, vd->part_name);
    dummy_obj_update(vd->layout);
 
+   vd->edj_reload_need = EINA_FALSE;
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+edj_changed_cb(void *data, int type EINA_UNUSED, void *event)
+{
+   view_data *vd = data;
+   Eio_Monitor_Event *ev = event;
+
+   if (vd->edj_monitor != ev->monitor) return ECORE_CALLBACK_PASS_ON;
+
+   //FIXME: why it need to add monitor again??
+   vd->edj_monitor = eio_monitor_add(config_edj_path_get());
+   if (!vd->edj_monitor) EINA_LOG_ERR("Failed to add Eio_Monitor!");
+
+   vd->edj_reload_need = EINA_TRUE;
+
    return ECORE_CALLBACK_DONE;
 }
 
@@ -292,6 +309,13 @@ view_init(Evas_Object *parent, const char *group,
    vd->monitor_event =
       ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, edj_changed_cb, vd);
 
+   /* Is this required?? Suddenly, something is changed and
+      it won't successful with EIO_MONITOR_FILE_MODIFIED to reload the edj file
+      since the file couldn't be accessed at the moment. To fix this problem,
+      we check the ECORE_EXE_EVENT_DEL additionally. */
+   vd->exe_del_event =
+      ecore_event_handler_add(ECORE_EXE_EVENT_DEL, exe_del_event_cb, vd);
+
    return vd;
 }
 
@@ -311,6 +335,7 @@ view_term(view_data *vd)
    ecore_timer_del(vd->timer);
    eio_monitor_del(vd->edj_monitor);
    ecore_event_handler_del(vd->monitor_event);
+   ecore_event_handler_del(vd->exe_del_event);
 
    free(vd);
 }
diff --git a/src/bin/main.c b/src/bin/main.c
index 862c86b..fde71ea 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -18,7 +18,6 @@ int main(int argc, char **argv);
 static Eina_Bool
 edc_changed_cb(void *data, int type EINA_UNUSED, void *event)
 {
-   //FIXME: Why does this callback called multiple times?
    Eio_Monitor_Event *ev = event;
    app_data *ad = data;
 

-- 


Reply via email to