efl_ui/layout: add explicit error case when theme version > efl version
authorMike Blumenkrantz <zmike@samsung.com>
Wed, 25 Sep 2019 11:30:24 +0000 (07:30 -0400)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 25 Sep 2019 21:12:44 +0000 (06:12 +0900)
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

src/lib/elementary/efl_ui.eot
src/lib/elementary/efl_ui_layout.c

index b397b27..eaa4ae4 100644 (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
 {
index 25b5876..49d0c44 100644 (file)
@@ -625,8 +625,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;
@@ -636,6 +639,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;
                }
           }
      }
@@ -655,6 +659,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;