summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-09-11 10:43:08 +0900
committerShinwoo Kim <cinoo.kim@samsung.com>2019-09-11 10:43:08 +0900
commit63fd44ef16723cfe52d4da196691b21483cf4aa4 (patch)
treebc845581e28f584026c551b1729880f32da521a7
parent09c3517d57f4ba34c662d93e101c494e5a839480 (diff)
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
-rw-r--r--src/lib/elementary/efl_ui_widget.c22
1 files 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,
4788EOLIAN static Eo * 4788EOLIAN static Eo *
4789_efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED) 4789_efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UNUSED)
4790{ 4790{
4791 Eina_Bool parent_is_widget = EINA_FALSE;
4792
4793 sd->on_create = EINA_TRUE; 4791 sd->on_create = EINA_TRUE;
4794 4792
4795 sd->window = efl_provider_find(efl_parent_get(obj), EFL_UI_WIN_CLASS); 4793 sd->window = efl_provider_find(efl_parent_get(obj), EFL_UI_WIN_CLASS);
4796 if (!efl_isa(obj, EFL_UI_WIN_CLASS)) 4794 if (!efl_isa(obj, EFL_UI_WIN_CLASS))
4797 { 4795 {
4798 Eo *parent = efl_parent_get(obj); 4796 Eo *parent = efl_parent_get(obj);
4799 parent_is_widget = efl_isa(parent, EFL_UI_WIDGET_CLASS); 4797 if (!efl_isa(parent, EFL_UI_WIDGET_CLASS))
4800 if (!parent_is_widget)
4801 { 4798 {
4802 ERR("You passed a wrong parent parameter (%p %s). " 4799 ERR("You passed a wrong parent parameter (%p %s). "
4803 "Elementary widget's parent should be an elementary widget.", 4800 "Elementary widget's parent should be an elementary widget.",
4804 parent, evas_object_type_get(parent)); 4801 parent, evas_object_type_get(parent));
4805 } 4802 }
4806 ELM_WIDGET_DATA_GET(parent, parent_sd);
4807 if (parent_sd)
4808 sd->shared_win_data = parent_sd->shared_win_data;
4809 else 4803 else
4810 sd->shared_win_data = efl_ui_win_shared_data_get(obj); 4804 {
4811 efl_ui_widget_sub_object_add(parent, obj); 4805 ELM_WIDGET_DATA_GET(parent, parent_sd);
4806 sd->shared_win_data = parent_sd->shared_win_data;
4807 efl_ui_widget_sub_object_add(parent, obj);
4808 }
4812 } 4809 }
4813 else 4810 else
4814 { 4811 {
@@ -4825,11 +4822,8 @@ _efl_ui_widget_efl_object_constructor(Eo *obj, Elm_Widget_Smart_Data *sd EINA_UN
4825 4822
4826 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_UNKNOWN); 4823 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_UNKNOWN);
4827 4824
4828 if (!sd->shared_win_data) 4825 if (!elm_widget_is_legacy(obj))
4829 { 4826 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->shared_win_data, NULL);
4830 if (sd->window && parent_is_widget)
4831 EINA_SAFETY_ON_NULL_RETURN_VAL(sd->shared_win_data, NULL);
4832 }
4833 4827
4834 return obj; 4828 return obj;
4835} 4829}