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 :(
This commit is contained in:
Jean-Philippe Andre 2017-02-21 16:14:20 +09:00
parent 3cb6d55ef0
commit aac07ca6c1
1 changed files with 16 additions and 1 deletions

View File

@ -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",