cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=9206960dfac9e2ad6651c69e24a3df5c1b92a2eb

commit 9206960dfac9e2ad6651c69e24a3df5c1b92a2eb
Author: Mike Blumenkrantz <zm...@samsung.com>
Date:   Wed Sep 25 07:30:24 2019 -0400

    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.b...@free.fr>
    Differential Revision: https://phab.enlightenment.org/D10153
---
 src/lib/elementary/efl_ui.eot      |  3 +++
 src/lib/elementary/efl_ui_layout.c | 15 +++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/lib/elementary/efl_ui.eot b/src/lib/elementary/efl_ui.eot
index b397b27094..eaa4ae41be 100644
--- a/src/lib/elementary/efl_ui.eot
+++ b/src/lib/elementary/efl_ui.eot
@@ -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
 {
diff --git a/src/lib/elementary/efl_ui_layout.c 
b/src/lib/elementary/efl_ui_layout.c
index ec5e731dfd..c4310f01c1 100644
--- a/src/lib/elementary/efl_ui_layout.c
+++ b/src/lib/elementary/efl_ui_layout.c
@@ -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;

-- 


Reply via email to