From: Enlightenment S. <no-...@en...> - 2008-10-20 20:34:29
|
Log: fix a segfault Author: urandom Date: 2008-10-20 13:34:24 -0700 (Mon, 20 Oct 2008) New Revision: 36874 Modified: trunk/edje_viewer/src/bin/edje_etk.c trunk/edje_viewer/src/bin/etk_gui.c Modified: trunk/edje_viewer/src/bin/edje_etk.c =================================================================== --- trunk/edje_viewer/src/bin/edje_etk.c 2008-10-20 20:03:42 UTC (rev 36873) +++ trunk/edje_viewer/src/bin/edje_etk.c 2008-10-20 20:34:24 UTC (rev 36874) @@ -31,12 +31,6 @@ static void message_cb(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg); -Evas_List *visible_elements = NULL; - -Evas_List *visible_elements_get() { - return visible_elements; -} - Demo_Edje *edje_part_create(Etk_Tree *output, Etk_Mdi_Area *mdi_area, const char *file, char *name) { Modified: trunk/edje_viewer/src/bin/etk_gui.c =================================================================== --- trunk/edje_viewer/src/bin/etk_gui.c 2008-10-20 20:03:42 UTC (rev 36873) +++ trunk/edje_viewer/src/bin/etk_gui.c 2008-10-20 20:34:24 UTC (rev 36874) @@ -59,6 +59,7 @@ /* Global variables */ static Evas_Object *Highlighter; +static Eina_List *visible_elements = NULL; void main_window_show(const char *file) { @@ -360,13 +361,17 @@ static void _open_edje_file(Gui *gui) { + Eina_List *l; + + visible_elements = eina_list_free(visible_elements); + _list_entries(gui->path, ETK_TREE(gui->tree)); etk_window_title_set(ETK_WINDOW(gui->win), gui->path); } static void _list_entries(const char *file, Etk_Tree *tree) { - Evas_List *entries = NULL, *collections = NULL; + Eina_List *entries = NULL, *collections = NULL; Etk_Tree_Col *col1; Etk_Tree_Row *row; Etk_Bool sort_parts; @@ -376,7 +381,7 @@ if (entries) { - Evas_List *l; + Eina_List *l; etk_tree_clear(tree); @@ -387,7 +392,7 @@ name = l->data; co = calloc(1, sizeof(Collection)); - collections = evas_list_append(collections, co); + collections = eina_list_append(collections, co); co->file = strdup(file); co->part = strdup(name); co->de = NULL; @@ -638,6 +643,7 @@ static Etk_Bool _gui_mdi_window_delete_event_cb(Etk_Mdi_Window *mdi __UNUSED__, Demo_Edje *de) { + if (!de) return ETK_FALSE; etk_tree_row_fields_set(de->tree_row, ETK_TRUE, de->tree_col, ETK_FALSE, NULL); return ETK_FALSE; } @@ -682,7 +688,7 @@ if (!co->de) { - Evas_List *l = NULL, *parts = NULL; + Eina_List *l = NULL, *parts = NULL; col1 = etk_tree_nth_col_get(row->tree, 0); co->de = edje_part_create(ETK_TREE(gui->output), @@ -691,7 +697,7 @@ co->de->tree_row = row; co->de->data = data; - parts = (Evas_List *) edje_edit_parts_list_get(co->de->edje_object); + parts = (Eina_List *) edje_edit_parts_list_get(co->de->edje_object); for (l = parts; l; l = l->next) { Etk_Tree_Row *child; @@ -707,11 +713,13 @@ mdi_win = co->de->mdi_window; if (checked) { + visible_elements = eina_list_append(visible_elements, co); etk_widget_show_all(mdi_win); etk_tree_row_unfold(row); } else { + visible_elements = eina_list_remove(visible_elements, co); if (co->de->part_row) etk_tree_row_fields_set(co->de->part_row, ETK_TRUE, col, ETK_FALSE, NULL); etk_widget_hide(mdi_win); @@ -764,7 +772,7 @@ static Etk_Bool _gui_emit_signal_cb(Etk_Object *obj __UNUSED__, void *data) { Gui * gui; - Evas_List *l; + Eina_List *l; const char *sig, *src; gui = data; @@ -774,13 +782,14 @@ src = etk_entry_text_get(ETK_ENTRY(gui->source_entry)); if (!sig) sig = ""; if (!src) src = ""; - for(l = visible_elements_get(); l; l = l->next) { - Demo_Edje *de; + for (l = visible_elements; l; l = l->next) + { + Collection *co; - de = l->data; - if (!de) continue; - edje_object_signal_emit(de->edje_object, sig, src); - } + co = l->data; + if (!co) continue; + edje_object_signal_emit(co->de->edje_object, sig, src); + } return ETK_TRUE; } @@ -833,6 +842,10 @@ Collection *co; co = data; - /* Do I need to free the members as well? */ - free(co); + if (co->de) + etk_mdi_window_delete_request(co->de->mdi_window); + FREE(co->part); + FREE(co->file); + FREE(co->de); + FREE(co); } |