From 65267ba2fdc38825c66e7aa27b0d8582aa54d43b Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Fri, 12 Aug 2016 03:55:51 +0900 Subject: [PATCH] file tab: stablizing file switching behavior. There are still corner case bugs. one is issued by unsafe thread working and the other one is group switching. fixed all in all. --- src/bin/file_mgr.c | 47 ++++++++++++++++------------------------ src/bin/file_tab.c | 3 +++ src/lib/edc_editor.c | 2 -- src/lib/edc_parser.c | 21 ++++++++++++++---- src/lib/edj_mgr.c | 2 ++ src/lib/enventor_smart.c | 5 ++++- 6 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/bin/file_mgr.c b/src/bin/file_mgr.c index 5b0aef8..0e47d02 100644 --- a/src/bin/file_mgr.c +++ b/src/bin/file_mgr.c @@ -278,44 +278,35 @@ file_mgr_main_file_set(const char *path) realpath = ecore_file_realpath(path); } - Eina_Bool same_file = EINA_FALSE; + //If this file is already openend with sub file, remove it. + Eina_List *sub_its = + (Eina_List *) enventor_object_sub_items_get(base_enventor_get()); + Eina_List *l; + Enventor_Item *it; - //Same with previous? + EINA_LIST_FOREACH(sub_its, l, it) + { + const char *path2 = enventor_item_file_get(it); + if (!path2) continue; + if (strcmp(realpath, path2)) continue; + file_mgr_file_del(it); + break; + } + + //Replace the current main file to a sub file. Enventor_Item *main_it = file_mgr_main_item_get(); if (main_it) { const char *prev_path = enventor_item_file_get(main_it); if (prev_path) { - if (!strcmp(prev_path, realpath)) same_file = EINA_TRUE; + const char *file_path = NULL; + file_path = enventor_item_file_get(main_it); + file_mgr_sub_file_add(file_path, EINA_FALSE); + file_mgr_file_del(main_it); } } - Enventor_Item *it; - - //If this file is already openend with sub file, remove it. - Eina_List *sub_its = - (Eina_List *) enventor_object_sub_items_get(base_enventor_get()); - Eina_List *l; - EINA_LIST_FOREACH(sub_its, l, it) - { - const char *path2 = enventor_item_file_get(it); - if (!path2) continue; - if (strcmp(realpath, path2)) continue; - file_tab_it_remove(it); - enventor_item_del(it); - break; - } - - //If main file is already openend, set it sub file first. - if (main_it && !same_file) - { - const char *file_path = NULL; - file_path = enventor_item_file_get(main_it); - file_mgr_sub_file_add(file_path, EINA_FALSE); - file_mgr_file_del(main_it); - } - main_it = enventor_object_main_item_set(base_enventor_get(), realpath); EINA_SAFETY_ON_NULL_RETURN_VAL(main_it, NULL); diff --git a/src/bin/file_tab.c b/src/bin/file_tab.c index 8bd5590..57b1580 100644 --- a/src/bin/file_tab.c +++ b/src/bin/file_tab.c @@ -59,6 +59,9 @@ list_item_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, if (fd->selected_it == it) return; file_tab_it *fti = data; + + //FIXME: If the item is going closed (by closed button) + //This focus is unnecessary! file_mgr_file_focus(fti->enventor_it); } diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c index 985123a..679e612 100644 --- a/src/lib/edc_editor.c +++ b/src/lib/edc_editor.c @@ -866,7 +866,6 @@ edit_cursor_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, edit_data *ed = data; cur_line_pos_set(ed, EINA_FALSE); edit_view_sync(ed); - bracket_update(ed); } @@ -1774,7 +1773,6 @@ edit_disabled_set(edit_data *ed, Eina_Bool disabled) //Turn off the part highlight in case of disable. if (disabled) view_part_highlight_set(VIEW_DATA, NULL); - else if (enventor_obj_part_highlight_get(ed->enventor)) edit_view_sync(ed); //Reset whatever ctrl pressed is on. ed->ctrl_pressed = EINA_FALSE; diff --git a/src/lib/edc_parser.c b/src/lib/edc_parser.c index 3533231..4e9dd36 100644 --- a/src/lib/edc_parser.c +++ b/src/lib/edc_parser.c @@ -1268,7 +1268,7 @@ static void bracket_thread_cancel(void *data, Ecore_Thread *thread EINA_UNUSED) { bracket_td *btd = data; - if (btd->pd && btd->pd->btd == btd) btd->pd->btd = NULL; + if (btd->pd) btd->pd->btd = NULL; free(btd->text); free(btd); } @@ -1288,7 +1288,11 @@ bracket_thread_end(void *data, Ecore_Thread *thread) void parser_cancel(parser_data *pd) { - if (pd->cntd) ecore_thread_cancel(pd->cntd->thread); + if (pd->cntd) + { + pd->cntd->pd = NULL; + ecore_thread_cancel(pd->cntd->thread); + } } char * @@ -1578,7 +1582,11 @@ parser_cur_context_get(parser_data *pd, Evas_Object *entry, Eina_Stringshare *group_name), void *data, Eina_Bool collections) { - if (pd->cntd) ecore_thread_cancel(pd->cntd->thread); + if (pd->cntd) + { + pd->cntd->pd = NULL; + ecore_thread_cancel(pd->cntd->thread); + } const char *text = elm_entry_entry_get(entry); if (!text) return; @@ -1892,7 +1900,11 @@ parser_macro_update(parser_data *pd, Eina_Bool macro_update) void parser_bracket_cancel(parser_data *pd) { - if (pd->btd) ecore_thread_cancel(pd->btd->thread); + if (pd->btd) + { + pd->btd->pd = NULL; + ecore_thread_cancel(pd->btd->thread); + } } void @@ -1901,6 +1913,7 @@ parser_bracket_find(parser_data *pd, Evas_Object *entry, { if (pd->btd) { + pd->btd->pd = NULL; ecore_thread_cancel(pd->btd->thread); } diff --git a/src/lib/edj_mgr.c b/src/lib/edj_mgr.c index 50c4fc0..fd560cd 100644 --- a/src/lib/edj_mgr.c +++ b/src/lib/edj_mgr.c @@ -132,6 +132,8 @@ edj_mgr_view_new(Enventor_Item *it, const char *group) { edj_mgr *em = g_em; + if (!group) return NULL; + edj_data *edj = calloc(1, sizeof(edj_data)); if (!edj) { diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c index e20a9ac..f5a870b 100644 --- a/src/lib/enventor_smart.c +++ b/src/lib/enventor_smart.c @@ -155,7 +155,7 @@ edit_view_sync_cb(void *data, Eina_Stringshare *state_name, double state_value, else { vd = edj_mgr_view_new(it, group_name); - if (!vd) return; + if (!vd) edj_mgr_view_switch_to(NULL); } view_dummy_set(vd, pd->dummy_parts); view_wireframes_set(vd, pd->wireframes); @@ -936,6 +936,9 @@ enventor_item_represent(Enventor_Item *it) if (pd->focused_it == it) return EINA_TRUE; + eina_stringshare_del(pd->group_name); + pd->group_name = NULL; + if (pd->focused_it) { edit_view_sync_cb_set(pd->focused_it->ed, NULL, NULL);