efl_ui/layout: add explicit error case when theme version > efl version

it's important to handle cases where a "future" theme is trying to be used
by "current" efl. this throws a serious error, since it's possible that the
widget may look/act in a way that makes it unusable

ref T8231

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10153
This commit is contained in:
Mike Blumenkrantz 2019-09-25 07:30:24 -04:00 committed by Cedric Bail
parent 71cd89c580
commit 9206960dfa
2 changed files with 16 additions and 2 deletions

View File

@ -11,6 +11,9 @@ error Efl.Ui.Theme.Apply_Error.DEFAULT = "Fallback to default style was enabled
error Efl.Ui.Theme.Apply_Error.GENERIC = "An error occurred and no theme could be set for this widget"; [[
Failed to apply theme. The widget may become unusable.
]]
error Efl.Ui.Theme.Apply_Error.VERSION = "The widget attempted to load a theme that is incompatible with the current EFL version"; [[
The theme was applied. The widget may not function or look as expected.
]]
enum Efl.Ui.Focus.Direction
{

View File

@ -545,8 +545,11 @@ _efl_ui_layout_base_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Layout_Data *sd)
{
const char *version = edje_object_data_get(wd->resize_obj, "version");
if (!version)
ERR("Widget(%p) with type '%s' is not providing a version in its theme!", obj,
efl_class_name_get(efl_class_get(obj)));
{
ERR("Widget(%p) with type '%s' is not providing a version in its theme!", obj,
efl_class_name_get(efl_class_get(obj)));
return EFL_UI_THEME_APPLY_ERROR_VERSION;
}
else
{
errno = 0;
@ -556,6 +559,7 @@ _efl_ui_layout_base_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Layout_Data *sd)
ERR("Widget(%p) with type '%s' is not providing a valid version in its theme!", obj,
efl_class_name_get(efl_class_get(obj)));
sd->version = 0;
return EFL_UI_THEME_APPLY_ERROR_VERSION;
}
}
}
@ -575,6 +579,13 @@ _efl_ui_layout_base_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Layout_Data *sd)
if (sd->version < version)
WRN("Widget(%p) with type '%s' is providing a potentially old version in its theme: found %u, should be %u", obj,
efl_class_name_get(efl_class_get(obj)), sd->version, version);
else if (sd->version > version)
{
CRI("Widget(%p) with type '%s' is attempting to use a theme that is too new: found %u, should be %u", obj,
efl_class_name_get(efl_class_get(obj)), sd->version, version);
CRI("\tTheme file: %s\tTheme group: %s", efl_file_get(obj), efl_file_key_get(obj));
return EFL_UI_THEME_APPLY_ERROR_VERSION;
}
}
return EFL_UI_THEME_APPLY_ERROR_NONE;