jpeg pushed a commit to branch master.

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

commit aac07ca6c1840cf6ad347134147582427af79e2e
Author: Jean-Philippe Andre <[email protected]>
Date:   Tue Feb 21 16:14:20 2017 +0900

    elm: Make clock widget more resilient to invalid config
    
    I was in a situation where my elm_config had the proper version
    but did not contain a proper module name for the clock widget.
    This resulted in not being able to create any field object in
    the clock widget... in other words it made for a very useless
    clock :)
    
    Ideally the config should be updated at this point. I'm not
    sure how to proceed exactly, though :(
---
 src/lib/elementary/efl_ui_clock.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/lib/elementary/efl_ui_clock.c 
b/src/lib/elementary/efl_ui_clock.c
index 7a61acd..fbdec4b 100644
--- a/src/lib/elementary/efl_ui_clock.c
+++ b/src/lib/elementary/efl_ui_clock.c
@@ -81,9 +81,23 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
 static Clock_Mod_Api *
 _dt_mod_init()
 {
+   static int tried_fallback = 0;
    Elm_Module *mod = NULL;
 
-   if (!(mod = _elm_module_find_as("clock/api"))) return NULL;
+   if (!(mod = _elm_module_find_as("clock/api")))
+     {
+        if (!tried_fallback &&
+            (!_elm_config->modules || !strstr(_elm_config->modules, 
"clock/api")))
+          {
+             // See also _config_update(): we hardcode here the default module
+             ERR("Elementary config does not contain the required module "
+                 "name for the clock widget! Verify your installation.");
+             _elm_module_add("clock_input_ctxpopup", "clock/api");
+             mod = _elm_module_find_as("clock/api");
+             tried_fallback = EINA_TRUE;
+          }
+        if (!mod) return NULL;
+     }
 
    mod->api = malloc(sizeof(Clock_Mod_Api));
    if (!mod->api) return NULL;
@@ -896,6 +910,7 @@ _efl_ui_clock_efl_canvas_group_group_add(Eo *obj, 
Efl_Ui_Clock_Data *priv)
                }
           }
      }
+   else WRN("Failed to load clock module, clock widget may not show 
properly!");
 
    priv->freeze_sizing = EINA_TRUE;
    if (!elm_layout_theme_set(obj, "uiclock", "base",

-- 


Reply via email to