From 63fd44ef16723cfe52d4da196691b21483cf4aa4 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 11 Sep 2019 10:43:08 +0900 Subject: [PATCH] efl_ui_widget: refactor constructor Summary: first of all, in efl-ui we should probebly ensure that a widget is always created in a window object. Otherwise we are looking for trouble. Additionally, calling efl_ui_win_shared_data_get on anything else than a window object will result in a returned NULL value. If we are not having a widget parent, there is also not much point in calling a API that is only defined on the widget base class, so we also move that away Reviewers: kimcinoo, raster Reviewed By: kimcinoo Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D9762 --- src/lib/elementary/efl_ui_widget.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c index 5a55e0aca2..9dc21e340d 100644 --- a/src/lib/elementary/efl_ui_widget.c +++ b/src/lib/elementary/efl_ui_widget.c @@ -4788,27 +4788,24 @@ elm_widget_tree_dot_dump(const Evas_Object *top, EOLIAN static Eo * _efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED) { - Eina_Bool parent_is_widget = EINA_FALSE; - sd->on_create = EINA_TRUE; sd->window = efl_provider_find(efl_parent_get(obj), EFL_UI_WIN_CLASS); if (!efl_isa(obj, EFL_UI_WIN_CLASS)) { Eo *parent = efl_parent_get(obj); - parent_is_widget = efl_isa(parent, EFL_UI_WIDGET_CLASS); - if (!parent_is_widget) + if (!efl_isa(parent, EFL_UI_WIDGET_CLASS)) { ERR("You passed a wrong parent parameter (%p %s). " "Elementary widget's parent should be an elementary widget.", parent, evas_object_type_get(parent)); } - ELM_WIDGET_DATA_GET(parent, parent_sd); - if (parent_sd) - sd->shared_win_data = parent_sd->shared_win_data; else - sd->shared_win_data = efl_ui_win_shared_data_get(obj); - efl_ui_widget_sub_object_add(parent, obj); + { + ELM_WIDGET_DATA_GET(parent, parent_sd); + sd->shared_win_data = parent_sd->shared_win_data; + efl_ui_widget_sub_object_add(parent, obj); + } } else { @@ -4825,11 +4822,8 @@ _efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UN efl_access_object_role_set(obj, EFL_ACCESS_ROLE_UNKNOWN); - if (!sd->shared_win_data) - { - if (sd->window && parent_is_widget) - EINA_SAFETY_ON_NULL_RETURN_VAL(sd->shared_win_data, NULL); - } + if (!elm_widget_is_legacy(obj)) + EINA_SAFETY_ON_NULL_RETURN_VAL(sd->shared_win_data, NULL); return obj; }