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.
This commit is contained in:
Hermet Park 2016-08-12 03:55:51 +09:00
parent ea4a177dcf
commit 65267ba2fd
6 changed files with 45 additions and 35 deletions

View File

@ -278,44 +278,35 @@ file_mgr_main_file_set(const char *path)
realpath = ecore_file_realpath(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(); Enventor_Item *main_it = file_mgr_main_item_get();
if (main_it) if (main_it)
{ {
const char *prev_path = enventor_item_file_get(main_it); const char *prev_path = enventor_item_file_get(main_it);
if (prev_path) 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); main_it = enventor_object_main_item_set(base_enventor_get(), realpath);
EINA_SAFETY_ON_NULL_RETURN_VAL(main_it, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(main_it, NULL);

View File

@ -59,6 +59,9 @@ list_item_selected_cb(void *data, Evas_Object *obj EINA_UNUSED,
if (fd->selected_it == it) return; if (fd->selected_it == it) return;
file_tab_it *fti = data; 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); file_mgr_file_focus(fti->enventor_it);
} }

View File

@ -866,7 +866,6 @@ edit_cursor_changed_cb(void *data, Evas_Object *obj EINA_UNUSED,
edit_data *ed = data; edit_data *ed = data;
cur_line_pos_set(ed, EINA_FALSE); cur_line_pos_set(ed, EINA_FALSE);
edit_view_sync(ed); edit_view_sync(ed);
bracket_update(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. //Turn off the part highlight in case of disable.
if (disabled) view_part_highlight_set(VIEW_DATA, NULL); 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. //Reset whatever ctrl pressed is on.
ed->ctrl_pressed = EINA_FALSE; ed->ctrl_pressed = EINA_FALSE;

View File

@ -1268,7 +1268,7 @@ static void
bracket_thread_cancel(void *data, Ecore_Thread *thread EINA_UNUSED) bracket_thread_cancel(void *data, Ecore_Thread *thread EINA_UNUSED)
{ {
bracket_td *btd = data; 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->text);
free(btd); free(btd);
} }
@ -1288,7 +1288,11 @@ bracket_thread_end(void *data, Ecore_Thread *thread)
void void
parser_cancel(parser_data *pd) 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 * char *
@ -1578,7 +1582,11 @@ parser_cur_context_get(parser_data *pd, Evas_Object *entry,
Eina_Stringshare *group_name), void *data, Eina_Stringshare *group_name), void *data,
Eina_Bool collections) 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); const char *text = elm_entry_entry_get(entry);
if (!text) return; if (!text) return;
@ -1892,7 +1900,11 @@ parser_macro_update(parser_data *pd, Eina_Bool macro_update)
void void
parser_bracket_cancel(parser_data *pd) 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 void
@ -1901,6 +1913,7 @@ parser_bracket_find(parser_data *pd, Evas_Object *entry,
{ {
if (pd->btd) if (pd->btd)
{ {
pd->btd->pd = NULL;
ecore_thread_cancel(pd->btd->thread); ecore_thread_cancel(pd->btd->thread);
} }

View File

@ -132,6 +132,8 @@ edj_mgr_view_new(Enventor_Item *it, const char *group)
{ {
edj_mgr *em = g_em; edj_mgr *em = g_em;
if (!group) return NULL;
edj_data *edj = calloc(1, sizeof(edj_data)); edj_data *edj = calloc(1, sizeof(edj_data));
if (!edj) if (!edj)
{ {

View File

@ -155,7 +155,7 @@ edit_view_sync_cb(void *data, Eina_Stringshare *state_name, double state_value,
else else
{ {
vd = edj_mgr_view_new(it, group_name); 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_dummy_set(vd, pd->dummy_parts);
view_wireframes_set(vd, pd->wireframes); view_wireframes_set(vd, pd->wireframes);
@ -936,6 +936,9 @@ enventor_item_represent(Enventor_Item *it)
if (pd->focused_it == it) return EINA_TRUE; if (pd->focused_it == it) return EINA_TRUE;
eina_stringshare_del(pd->group_name);
pd->group_name = NULL;
if (pd->focused_it) if (pd->focused_it)
{ {
edit_view_sync_cb_set(pd->focused_it->ed, NULL, NULL); edit_view_sync_cb_set(pd->focused_it->ed, NULL, NULL);