rimmed pushed a commit to branch master. http://git.enlightenment.org/tools/eflete.git/commit/?id=47f6bdf04df1b1db263f0f8aa9f899ee51fd1b64
commit 47f6bdf04df1b1db263f0f8aa9f899ee51fd1b64 Author: Vitalii Vorobiov <[email protected]> Date: Fri Jul 1 16:01:30 2016 +0300 history_ui: avoid SIGSEV for now cleanup hoversel on selected and apply on dismiss @fix --- src/bin/ui/history_ui.c | 106 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 28 deletions(-) diff --git a/src/bin/ui/history_ui.c b/src/bin/ui/history_ui.c index 0e4cf89..db75428 100644 --- a/src/bin/ui/history_ui.c +++ b/src/bin/ui/history_ui.c @@ -39,9 +39,23 @@ typedef struct { History_New_UI_data *hd = evas_object_data_get(OBJ, HISTORY_DATA); \ assert(hd != NULL); +/* first invoke this function, then second */ static void -_list_update(History_New_UI_data *hd) +_list_cleanup(History_New_UI_data *hd) { + assert(hd != NULL); + + /* removing all reverted changes because the were deleted from history */ + elm_hoversel_clear(hd->undo_cmbx); + elm_hoversel_clear(hd->redo_cmbx); +} + +static void +_expanded_undo(void *data, + Evas_Object *obj __UNUSED__, + void *ei __UNUSED__) +{ + History_New_UI_data *hd = data; Change *change = NULL; Eina_List *l = NULL; unsigned int i = 0; @@ -49,13 +63,7 @@ _list_update(History_New_UI_data *hd) assert(hd != NULL); - /* removing all reverted changes because the were deleted from history */ - elm_hoversel_clear(hd->undo_cmbx); - elm_hoversel_clear(hd->redo_cmbx); - hd->to_undo = 0; - hd->to_redo = 0; - Eina_List *reverse_redo = NULL; EINA_LIST_REVERSE_FOREACH(hd->history->changes, l, change) { if (!change->reverted) @@ -63,30 +71,49 @@ _list_update(History_New_UI_data *hd) hd->to_undo++; hoversel_it = elm_hoversel_item_add(hd->undo_cmbx, change->description, NULL, ELM_ICON_NONE, NULL, NULL); evas_object_data_set(hoversel_it, "number", (void*)(uintptr_t)i); - printf("UNDO\n"); i++; } - else - { - hd->to_redo++; - reverse_redo = eina_list_append(reverse_redo, change); - } } +} + +static void +_expanded_redo(void *data, + Evas_Object *obj __UNUSED__, + void *ei __UNUSED__) +{ + History_New_UI_data *hd = data; + Change *change = NULL; + Eina_List *l = NULL; + unsigned int i = 0; + Elm_Object_Item *hoversel_it; + + assert(hd != NULL); - i = 0; - EINA_LIST_REVERSE_FOREACH(reverse_redo, l, change) + hd->to_redo = 0; + EINA_LIST_FOREACH(hd->history->changes, l, change) { - hoversel_it = elm_hoversel_item_add(hd->redo_cmbx, change->description, NULL, ELM_ICON_NONE, NULL, NULL); - evas_object_data_set(hoversel_it, "number", (void*)(uintptr_t)i); - printf("REDO\n"); - i++; + if (change->reverted) + { + hd->to_redo++; + hoversel_it = elm_hoversel_item_add(hd->redo_cmbx, change->description, NULL, ELM_ICON_NONE, NULL, NULL); + evas_object_data_set(hoversel_it, "number", (void*)(uintptr_t)i); + i++; + } } } static void +_undo_item_cleanup(void *data, + Evas_Object *obj __UNUSED__, + void *ei __UNUSED__) +{ + History_New_UI_data *hd = data; + _list_cleanup(hd); +} +static void _undo_item_selected(void *data, Evas_Object *obj __UNUSED__, - void *ei) + void *ei __UNUSED__) { History_New_UI_data *hd = data; int i; @@ -95,13 +122,24 @@ _undo_item_selected(void *data, assert(hd != NULL); for (i = 0; i <= index; i++) - CRIT_ON_FAIL(history_undo(hd->history)); + { + CRIT_ON_FAIL(history_undo(hd->history)); + hd->to_undo--; + hd->to_redo++; + } evas_object_smart_callback_call(ap.win, SIGNAL_PROPERTY_ATTRIBUTE_CHANGED, NULL); - _list_update(hd); } static void +_redo_item_cleanup(void *data, + Evas_Object *obj __UNUSED__, + void *ei __UNUSED__) +{ + History_New_UI_data *hd = data; + _list_cleanup(hd); +} +static void _redo_item_selected(void *data, Evas_Object *obj __UNUSED__, void *ei) @@ -113,10 +151,13 @@ _redo_item_selected(void *data, assert(hd != NULL); for (i = 0; i <= index; i++) - CRIT_ON_FAIL(history_redo(hd->history)); + { + CRIT_ON_FAIL(history_redo(hd->history)); + hd->to_redo--; + hd->to_undo++; + } evas_object_smart_callback_call(ap.win, SIGNAL_PROPERTY_ATTRIBUTE_CHANGED, NULL); - _list_update(hd); } void @@ -124,8 +165,9 @@ history_ui_undo(Evas_Object *obj) { HISTORY_DATA_GET(obj); if (hd->to_undo == 0) return; + hd->to_undo--; + hd->to_redo++; history_undo(hd->history); - _list_update(hd); } void @@ -133,15 +175,17 @@ history_ui_redo(Evas_Object *obj) { HISTORY_DATA_GET(obj); if (hd->to_redo == 0) return; + hd->to_redo--; + hd->to_undo++; history_redo(hd->history); - _list_update(hd); } void history_ui_update(Evas_Object *obj) { HISTORY_DATA_GET(obj); - _list_update(hd); + hd->to_redo = 0; + hd->to_undo++; } static void @@ -162,7 +206,6 @@ _btn_redo_cb(void *data __UNUSED__, history_ui_redo(hd->layout); } - Evas_Object * history_ui_add(Evas_Object *parent, History *history) { @@ -187,11 +230,15 @@ history_ui_add(Evas_Object *parent, History *history) elm_object_part_content_set(undo_layout, "button", btn); hd->undo_cmbx = elm_hoversel_add(hd->layout); + elm_hoversel_auto_update_set(hd->undo_cmbx, false); elm_hoversel_hover_parent_set(hd->undo_cmbx, ap.win); evas_object_size_hint_weight_set(hd->undo_cmbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(hd->undo_cmbx, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_style_set(hd->undo_cmbx, "history"); + evas_object_smart_callback_add(hd->undo_cmbx, "clicked", _expanded_undo, hd); evas_object_smart_callback_add(hd->undo_cmbx, "selected", _undo_item_selected, hd); + evas_object_smart_callback_add(hd->undo_cmbx, "dismissed", _undo_item_cleanup, hd); + evas_object_show(hd->undo_cmbx); elm_object_part_content_set(undo_layout, "arrow", hd->undo_cmbx); elm_object_part_content_set(hd->layout, "undo", undo_layout); @@ -207,11 +254,14 @@ history_ui_add(Evas_Object *parent, History *history) elm_object_part_content_set(redo_layout, "button", btn); hd->redo_cmbx = elm_hoversel_add(hd->layout); + elm_hoversel_auto_update_set(hd->redo_cmbx, false); elm_hoversel_hover_parent_set(hd->redo_cmbx, ap.win); evas_object_size_hint_weight_set(hd->redo_cmbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(hd->redo_cmbx, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_object_style_set(hd->redo_cmbx, "history"); + evas_object_smart_callback_add(hd->redo_cmbx, "clicked", _expanded_redo, hd); evas_object_smart_callback_add(hd->redo_cmbx, "selected", _redo_item_selected, hd); + evas_object_smart_callback_add(hd->redo_cmbx, "dismissed", _redo_item_cleanup, hd); evas_object_show(hd->redo_cmbx); elm_object_part_content_set(redo_layout, "arrow", hd->redo_cmbx); elm_object_part_content_set(hd->layout, "redo", redo_layout); --
