From e62b07f7797f312cbe031334c771c3efedc183fc Mon Sep 17 00:00:00 2001 From: Lukasz Stanislawski Date: Wed, 14 May 2014 12:02:10 +0900 Subject: [PATCH] layout: remove sizing_eval call when layout is already destructed. @fix Summary: Layout's sub_object_del function calls sizing_eval even if layout's smart_del function has already been called (Due to widget_smart_del impl). This patch adds 'destructed_is' flag to Elm_Layout_Smart_Data and prevents unneeded sizing_eval calls when object is already destructed. Patch also fixes SIGSEGV in layout derived entry widget caused by calling sizing_eval after entry_smart_del destructor. Added entry test to avoid regression for SIGSEGV bug. Test Plan: run tests/elm_test_entry Reviewers: raster, seoz, tasn, cedric Differential Revision: https://phab.enlightenment.org/D823 --- legacy/elementary/src/lib/elm_layout.c | 3 +++ legacy/elementary/src/lib/elm_widget_layout.h | 1 + legacy/elementary/src/tests/Makefile.am | 1 + legacy/elementary/src/tests/elm_suite.c | 1 + legacy/elementary/src/tests/elm_suite.h | 1 + legacy/elementary/src/tests/elm_test_entry.c | 25 +++++++++++++++++++ 6 files changed, 32 insertions(+) create mode 100644 legacy/elementary/src/tests/elm_test_entry.c diff --git a/legacy/elementary/src/lib/elm_layout.c b/legacy/elementary/src/lib/elm_layout.c index 0e62d89cdf..d6fa3fc65e 100644 --- a/legacy/elementary/src/lib/elm_layout.c +++ b/legacy/elementary/src/lib/elm_layout.c @@ -520,6 +520,7 @@ _elm_layout_elm_widget_sub_object_del(Eo *obj, Elm_Layout_Smart_Data *sd, Evas_O eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_sub_object_del(sobj)); if (!int_ret) return EINA_FALSE; + if (sd->destructed_is) return EINA_TRUE; EINA_LIST_FOREACH(sd->subs, l, sub_d) { @@ -799,6 +800,8 @@ _elm_layout_evas_smart_del(Eo *obj, Elm_Layout_Smart_Data *sd) } } + sd->destructed_is = EINA_TRUE; + eo_do_super(obj, MY_CLASS, evas_obj_smart_del()); } diff --git a/legacy/elementary/src/lib/elm_widget_layout.h b/legacy/elementary/src/lib/elm_widget_layout.h index 0d7b8d7f94..f005dd9d39 100644 --- a/legacy/elementary/src/lib/elm_widget_layout.h +++ b/legacy/elementary/src/lib/elm_widget_layout.h @@ -77,6 +77,7 @@ typedef struct _Elm_Layout_Smart_Data Eina_Bool restricted_calc_w : 1; Eina_Bool restricted_calc_h : 1; Eina_Bool can_access : 1; /**< This is true when all text(including textblock) parts can be accessible by accessibility. */ + Eina_Bool destructed_is : 1; /**< This flag indicates if Elm_Layout destructor was called */ } Elm_Layout_Smart_Data; /** diff --git a/legacy/elementary/src/tests/Makefile.am b/legacy/elementary/src/tests/Makefile.am index 84c763bb4b..200ada7fa8 100644 --- a/legacy/elementary/src/tests/Makefile.am +++ b/legacy/elementary/src/tests/Makefile.am @@ -8,6 +8,7 @@ elm_suite_SOURCES = \ elm_suite.c \ elm_test_check.c \ elm_test_colorselector.c \ + elm_test_entry.c \ elm_test_init.c elm_suite_CPPFLAGS = \ diff --git a/legacy/elementary/src/tests/elm_suite.c b/legacy/elementary/src/tests/elm_suite.c index 7056b35fe8..f5868335b2 100644 --- a/legacy/elementary/src/tests/elm_suite.c +++ b/legacy/elementary/src/tests/elm_suite.c @@ -17,6 +17,7 @@ static const Elementary_Test_Case etc[] = { { "Elementary", elm_test_init }, { "elm_check", elm_test_check }, { "elm_colorselector", elm_test_colorselector }, + { "elm_entry", elm_test_entry}, { NULL, NULL } }; diff --git a/legacy/elementary/src/tests/elm_suite.h b/legacy/elementary/src/tests/elm_suite.h index 3d4be29483..bac0a5692d 100644 --- a/legacy/elementary/src/tests/elm_suite.h +++ b/legacy/elementary/src/tests/elm_suite.h @@ -6,5 +6,6 @@ void elm_test_init(TCase *tc); void elm_test_check(TCase *tc); void elm_test_colorselector(TCase *tc); +void elm_test_entry(TCase *tc); #endif /* _ELM_SUITE_H */ diff --git a/legacy/elementary/src/tests/elm_test_entry.c b/legacy/elementary/src/tests/elm_test_entry.c new file mode 100644 index 0000000000..70643aed21 --- /dev/null +++ b/legacy/elementary/src/tests/elm_test_entry.c @@ -0,0 +1,25 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#include +#include "elm_suite.h" + +START_TEST (elm_entry_del) +{ + Evas_Object *win, *entry; + + elm_init(1, NULL); + win = elm_win_add(NULL, "check", ELM_WIN_BASIC); + + entry = elm_entry_add(win); + elm_object_text_set(entry, "TEST"); + + elm_shutdown(); +} +END_TEST + +void elm_test_entry(TCase *tc) +{ + tcase_add_test(tc, elm_entry_del); +}