yakov pushed a commit to branch master.

http://git.enlightenment.org/tools/erigo.git/commit/?id=7e7ec9e41e12fa41a6bbf64c11de9a3ad26a30ae

commit 7e7ec9e41e12fa41a6bbf64c11de9a3ad26a30ae
Author: Yakov Goldberg <yako...@samsung.com>
Date:   Sun Apr 10 18:53:29 2016 +0300

    Fix memory leaks
---
 src/bin/gui/cbview.c          | 10 ++--------
 src/bin/gui/contentview.c     |  1 +
 src/bin/gui/descview.c        |  1 +
 src/bin/gui/dnd.h             |  3 +++
 src/bin/gui/editor.c          | 19 +++++++++++++++----
 src/bin/gui/egui_logic.c      |  2 +-
 src/bin/gui/itemview.c        |  1 +
 src/bin/gui/prop_layout.c     |  3 +--
 src/bin/gui/settings.c        |  2 ++
 src/bin/gui/simple_propview.c |  2 ++
 src/lib/desc_simple_parser.c  |  1 +
 src/lib/gui_parser.c          |  3 +++
 src/lib/updater.c             | 11 +++++++----
 13 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/src/bin/gui/cbview.c b/src/bin/gui/cbview.c
index 621c142..683b67d 100644
--- a/src/bin/gui/cbview.c
+++ b/src/bin/gui/cbview.c
@@ -492,13 +492,6 @@ _item_del(void *data, Evas_Object *obj EINA_UNUSED)
    _it_data_free(it_data);
 }
 
-static Eina_Bool
-_wdgs_struct_free(void *wdgs, const Eo_Event *event EINA_UNUSED)
-{
-   free(wdgs);
-   return EINA_TRUE;
-}
-
 static Evas_Object *
 _item_content_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part 
EINA_UNUSED)
 {
@@ -520,7 +513,6 @@ _item_content_get(void *data, Evas_Object *obj EINA_UNUSED, 
const char *part EIN
      {
         wdgs = egui_layout_cb_item_create(propview_table);
         eo_key_data_set(wdgs->cb_item, "cb_item_wdgs", wdgs);
-        eo_event_callback_add(wdgs->cb_item, EO_BASE_EVENT_DEL, 
_wdgs_struct_free, wdgs);
         elm_hoversel_item_add(wdgs->cb_action_t_hsel, "Create", NULL, 
ELM_ICON_NONE, NULL, NULL);
         elm_hoversel_item_add(wdgs->cb_action_t_hsel, "Modify", NULL, 
ELM_ICON_NONE, NULL, NULL);
         elm_hoversel_item_add(wdgs->cb_action_t_hsel, "Invoke", NULL, 
ELM_ICON_NONE, NULL, NULL);
@@ -647,6 +639,8 @@ cbview_build(const Gui_Widget *wdg)
 {
    elm_obj_genlist_clear(cb_list);
 
+   if (!wdg) return;
+
    Eina_List *classes = eo_class_mro_get(wdg_class_name_get(wdg));
    const char *classname;
    Elm_Object_Item *glit = NULL;
diff --git a/src/bin/gui/contentview.c b/src/bin/gui/contentview.c
index 58e8eb5..efe7e6d 100644
--- a/src/bin/gui/contentview.c
+++ b/src/bin/gui/contentview.c
@@ -96,6 +96,7 @@ contentview_build(const Gui_Widget *wdg)
    It_Data *it_data;
 
    elm_obj_genlist_clear(ctn_list);
+   if (!wdg) return;
 
    const char *wdg_name = wdg_obj_container_class_name_get(wdg);
    Eina_Bool isbox = (wdg_name &&
diff --git a/src/bin/gui/descview.c b/src/bin/gui/descview.c
index ba33d28..ebf5160 100644
--- a/src/bin/gui/descview.c
+++ b/src/bin/gui/descview.c
@@ -19,6 +19,7 @@ void
 descview_build(const Gui_Widget *wdg)
 {
    elm_obj_genlist_clear(desc_list);
+   if (!wdg) return;
 
    int i;
    for (i = 0; descs[i]; i++)
diff --git a/src/bin/gui/dnd.h b/src/bin/gui/dnd.h
index 884bb3e..3e04a3d 100644
--- a/src/bin/gui/dnd.h
+++ b/src/bin/gui/dnd.h
@@ -26,6 +26,9 @@ drop_item_container_del(Eo *obj);
 void
 drag_item_container_set(Eo *obj, double anim_tm, double tm_to_drag, 
Elm_Drag_Start dragstart, Elm_Drag_Done dragdone);
 
+void
+drag_item_container_del(Eo *obj);
+
 const Gui_Widget *
 dnd_drag_wdg_get();
 
diff --git a/src/bin/gui/editor.c b/src/bin/gui/editor.c
index 93b0d83..7c9ee63 100644
--- a/src/bin/gui/editor.c
+++ b/src/bin/gui/editor.c
@@ -344,11 +344,12 @@ static void
 _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool visibility, int 
border_type_color)
 {
    const Gui_Context *ctx = _active_context_get();
-   if (!ctx) return;
-   const Gui_Session *session = gui_context_editor_session_get(ctx);
-   static Eo *_base_obj_prev = NULL;
    Eo *obj = NULL;
    Eo *base_obj = canvas_get();
+
+   if (!ctx && !visibility) goto hide_borders;
+   const Gui_Session *session = gui_context_editor_session_get(ctx);
+   static Eo *_base_obj_prev = NULL;
    if (wdg)
      {
         if (IS_MAIN(wdg))
@@ -436,6 +437,7 @@ _wdg_border_draw(const Gui_Widget *wdg, Eina_Bool 
visibility, int border_type_co
           }
      }
 
+hide_borders:
    switch (border_type_color)
      {
       case BORDER_SELECTION:
@@ -3395,6 +3397,7 @@ _editor_selected_wdg_del_cb()
    context_memento_finalize(ctx);
 }
 
+static Ecore_Idler *_border_draw_idler = NULL;
 void
 editor_shutdown()
 {
@@ -3402,12 +3405,19 @@ editor_shutdown()
    eo_key_data_del(g->main_win->canvas_scroller, EDITOR_DND_DATA);
    free(di);
    drop_target_wdg_del(NULL, g->main_win->canvas_scroller);
+   drop_item_container_del(g->main_win->objtree_list);
+   drag_item_container_del(g->main_win->objtree_list);
+
+   ecore_idle_enterer_del(_border_draw_idler);
+   _border_draw_idler = NULL;
 
    target_db_shutdown();
    proplayout_shutdown();
    objtree_shutdown();
    autosave_shutdown();
 
+   elm_obj_grid_clear(canvas_get(), EINA_TRUE);
+
    void *p = (void *) propview_cbs_get();
    free(p);
    p = (void *) guilogic_cbs_get();
@@ -4470,6 +4480,7 @@ static void
 _project_close(const Gui_Context *ctx)
 {
    /* Clear lists. */
+   _editor_wdg_selected_set(NULL);
    objtree_context_set(NULL);
    proplayout_build(NULL);
    if (ctx)
@@ -5027,7 +5038,7 @@ editor_init(GuiLogicCbs *_guilogic_cbs)
    proplayout_init();
    target_db_init();
    autosave_init();
-   ecore_idle_enterer_add(_wdg_border_draw_on_idle, NULL);
+   _border_draw_idler = ecore_idle_enterer_add(_wdg_border_draw_on_idle, NULL);
 
    DnD_Main_Obj_Info *di = calloc (1, sizeof(DnD_Main_Obj_Info));
    eo_key_data_set(g->main_win->canvas_scroller, EDITOR_DND_DATA, di);
diff --git a/src/bin/gui/egui_logic.c b/src/bin/gui/egui_logic.c
index d77e0c1..c94473e 100644
--- a/src/bin/gui/egui_logic.c
+++ b/src/bin/gui/egui_logic.c
@@ -363,9 +363,9 @@ project_open_create(const char *filename, int fs_mode, 
const char *dir, const ch
              const char *title = "Warning";
              const char *text = "Swap file exists for current project. Looks 
like file was not properly saved. Do you want to open swap file instead of 
original ?";
              popup_show(g_main_wdgs->main_win->main_win, title, text, NULL, 
NULL, POPUP_OK_BUTTON | POPUP_CANCEL_BUTTON, _swapfile_popup_cb, 
strdup(filename));
-             free(swap_file);
              ret = EINA_TRUE;
           }
+        free(swap_file);
         if (ret) return;
         _project_open_create_internal(filename, fs_mode, NULL, NULL, NULL);
      }
diff --git a/src/bin/gui/itemview.c b/src/bin/gui/itemview.c
index dfaf61e..a730bb9 100644
--- a/src/bin/gui/itemview.c
+++ b/src/bin/gui/itemview.c
@@ -228,6 +228,7 @@ itemview_build(const Gui_Widget *wdg)
 #else
    _witems_to_items_table = eina_hash_int32_new(NULL);
 #endif
+   if (!wdg) return;
 
    /* During first build, only headed widgets are added. */
    const Item_Container_Item *root_it = wdg_item_container_root_get(wdg);
diff --git a/src/bin/gui/prop_layout.c b/src/bin/gui/prop_layout.c
index 75348bb..dbcac97 100644
--- a/src/bin/gui/prop_layout.c
+++ b/src/bin/gui/prop_layout.c
@@ -215,7 +215,7 @@ proplayout_build(const Gui_Widget *wdg)
 {
    It_Data_Type type = _new_type;
 
-   if (!wdg) return;
+   //if (!wdg) return;
 
    /* type ITEM_TYPE not assigned to any toolbar's item.
     * It's assigned when toolbar's item is CONTENT and widget is menu.
@@ -257,7 +257,6 @@ proplayout_build(const Gui_Widget *wdg)
            }
       case ITEM_TYPE:
            {
-              itemview_clear();
               itemview_build(wdg);
               break;
            }
diff --git a/src/bin/gui/settings.c b/src/bin/gui/settings.c
index b6d8bf6..2eef534 100644
--- a/src/bin/gui/settings.c
+++ b/src/bin/gui/settings.c
@@ -103,11 +103,13 @@ settings_load()
              s = eina_json_string_get(v);
              settings_custom_theme_add(s);
           }
+        eina_iterator_free(it);
      }
 
 end:
    if (jv) eina_json_value_free(jv);
    if (ctx) eina_json_context_free(ctx);
+   if (file_data) free(file_data);
    return ret;
 }
 
diff --git a/src/bin/gui/simple_propview.c b/src/bin/gui/simple_propview.c
index 84be60b..8743a35 100644
--- a/src/bin/gui/simple_propview.c
+++ b/src/bin/gui/simple_propview.c
@@ -518,6 +518,8 @@ simple_propview_build(const Gui_Widget *wdg)
 
    elm_obj_box_clear(_simple_properties_box);
 
+   if (!wdg) return;
+
    simple_op_desc_list = simple_op_desc_list_get();
    EINA_LIST_FOREACH(simple_op_desc_list, itr1, simple_op_desc)
      {
diff --git a/src/lib/desc_simple_parser.c b/src/lib/desc_simple_parser.c
index 0e821e1..bfd4d1b 100644
--- a/src/lib/desc_simple_parser.c
+++ b/src/lib/desc_simple_parser.c
@@ -638,6 +638,7 @@ _parse_simple_op_desc(void)
    sop = simple_op_desc_get(simple_op_name);
    simple_op_desc_section_name_set(sop, section_name);
    DEBUG("Handling Simple Op %p (%s)\n", sop, simple_op_name);
+   free(section_name);
    free(str);
 
    if (_next_keyword("as"))
diff --git a/src/lib/gui_parser.c b/src/lib/gui_parser.c
index 20ef0cc..b1a8e8b 100644
--- a/src/lib/gui_parser.c
+++ b/src/lib/gui_parser.c
@@ -558,6 +558,7 @@ _widget_parse(Gui_Context *gui_ctx, Eid *eid, 
Eina_Json_Value *widget_js, Eina_B
                     {
                        ERR("Cannot find op description: \"%s\" for class: 
\"%s\"\n"
                            "Property will not take effect.", prop_name, 
class_name);
+                       free(prop_name_tmp);
                        continue;
                     }
                   Gui_Widget_Property *prop = prop_create_for_op(op);
@@ -570,6 +571,7 @@ _widget_parse(Gui_Context *gui_ctx, Eid *eid, 
Eina_Json_Value *widget_js, Eina_B
                     {
                        ERR("Parsing error! Widget: \"%s\", property: \"%s\". 
Param count: %d, should be: %d.",
                            widget_name, prop_name, json_arr_param_count, 
db_param_count);
+                       free(prop_name_tmp);
                        goto bad_end;
                     }
 
@@ -1005,6 +1007,7 @@ _settings_parse(Gui_Context *gui_ctx, Eina_Json_Value 
*res_js)
               gui_context_project_path_get(gui_ctx), val);
         basedir_abs = eina_file_path_sanitize(basedir_rel);
         gui_context_project_basedir_abs_set(gui_ctx, basedir_abs);
+        free(basedir_abs);
      }
    ret = EINA_TRUE;
    return ret;
diff --git a/src/lib/updater.c b/src/lib/updater.c
index 714dea7..ce446cb 100644
--- a/src/lib/updater.c
+++ b/src/lib/updater.c
@@ -112,9 +112,12 @@ _eo_add_apply(const Eina_List *sessions, Eid *eid)
      {
         if (session_eo_get(s, wdg)) continue;
         manager_widget_create(s, wdg, NULL);
-        _resize_cb_added = EINA_TRUE;
-        _resize_cb_called = EINA_FALSE;
-        eo_event_callback_add(session_eo_get(s, wdg), 
EVAS_OBJECT_EVENT_RESIZE, _resized_cb, NULL);
+        if (!IS_MAIN(wdg))
+          {
+             _resize_cb_added = EINA_TRUE;
+             _resize_cb_called = EINA_FALSE;
+             eo_event_callback_add(session_eo_get(s, wdg), 
EVAS_OBJECT_EVENT_RESIZE, _resized_cb, NULL);
+          }
      }
 }
 
@@ -334,7 +337,7 @@ _update_check(void *data EINA_UNUSED)
      }
    else
      {
-        if (!_resize_cb_added || (_resize_cb_added && _resize_cb_called) )
+        if (!_resize_cb_added || (_resize_cb_added && _resize_cb_called))
           {
              Eina_List *itr2;
              Completion_Info *info;

-- 


Reply via email to