efl_ui_widget: keep backward compatibility

It was possilbe to add an image with improper parent object before aa2d94f and
56752e0. This patch makes it possible. Sure there are error messages when user
adds an image object using non widget object as below but you can see image.

ERR<28822>:elementary ../src/lib/elementary/efl_ui_widget.c:4801 _efl_ui_widget_efl_object_constructor() You passed a wrong parent parameter (0x400000007ced (null)). Elementary widget's parent should be an elementary widget.
ERR<28822>:elementary ../src/lib/elementary/efl_ui_widget.c:4803 _efl_ui_widget_efl_object_constructor() No widget data for object 0x400000007ced ((null))
ERR<28822>:eina_safety ../src/lib/elementary/efl_ui_win.c:9450 efl_ui_win_shared_data_get() safety check failed: pd == NULL
ERR<28822>:eo ../src/lib/eo/eo.c:579 _efl_object_call_resolve() in src/lib/elementary/efl_ui_widget.eo.c:256: func 'efl_ui_widget_sub_object_add' (698) could not be resolved for class 'Evas.Canvas'.

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D9747
This commit is contained in:
Shinwoo Kim 2019-08-27 10:27:01 +00:00 committed by Marcel Hollerbach
parent 05ea1854a9
commit cfc0d4866c
3 changed files with 15 additions and 6 deletions

View File

@ -40,7 +40,8 @@ _efl_ui_focus_parent_provider_gen_container_set(Eo *obj, Efl_Ui_Focus_Parent_Pro
ELM_WIDGET_DATA_GET(pd->container, wid_pd);
((Efl_Ui_Shared_Win_Data*)wid_pd->shared_win_data)->custom_parent_provider = EINA_TRUE;
if (wid_pd->shared_win_data)
((Efl_Ui_Shared_Win_Data*)wid_pd->shared_win_data)->custom_parent_provider = EINA_TRUE;
}
EOLIAN static Efl_Ui_Widget*

View File

@ -396,7 +396,7 @@ _eval_registration_candidate(Eo *obj, Elm_Widget_Smart_Data *pd, Eina_Bool *shou
pd->tree_unfocusable > 0)
return;
if (((Efl_Ui_Shared_Win_Data*)pd->shared_win_data)->legacy_focus_api_used)
if (!pd->shared_win_data || ((Efl_Ui_Shared_Win_Data*)pd->shared_win_data)->legacy_focus_api_used)
{
if (_legacy_focus_eval(obj))
return;
@ -456,7 +456,7 @@ _logical_parent_eval(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina_Bool s
Efl_Ui_Widget *parent;
Efl_Ui_Focus_Parent_Provider *provider;
if (((Efl_Ui_Shared_Win_Data*)pd->shared_win_data)->custom_parent_provider)
if (!pd->shared_win_data || ((Efl_Ui_Shared_Win_Data*)pd->shared_win_data)->custom_parent_provider)
{
if (should)
{
@ -4788,13 +4788,16 @@ 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);
if (!efl_isa(parent, EFL_UI_WIDGET_CLASS))
parent_is_widget = efl_isa(parent, EFL_UI_WIDGET_CLASS);
if (!parent_is_widget)
{
ERR("You passed a wrong parent parameter (%p %s). "
"Elementary widget's parent should be an elementary widget.",
@ -4822,7 +4825,11 @@ _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);
EINA_SAFETY_ON_NULL_RETURN_VAL(sd->shared_win_data, NULL);
if (!sd->shared_win_data)
{
if (sd->window && parent_is_widget)
EINA_SAFETY_ON_NULL_RETURN_VAL(sd->shared_win_data, NULL);
}
return obj;
}

View File

@ -22,7 +22,8 @@
EINA_SAFETY_ON_FALSE_RETURN_VAL(elm_widget_is_legacy(obj), val);
#define MARK_WINDOW_LEGACY_USAGE() \
((Efl_Ui_Shared_Win_Data*)pd->shared_win_data)->legacy_focus_api_used = EINA_TRUE;
if (pd->shared_win_data) \
((Efl_Ui_Shared_Win_Data*)pd->shared_win_data)->legacy_focus_api_used = EINA_TRUE;
#define MAPPING() \
MAP(PREVIOUS, prev) \