edje/load: (more) correctly handle part updates after changing edje group

Summary:
if a part changes its type, verify that the new type is compatible AND
exists before attempting to re-set the previous state, otherwise take
action and print warning

@fix
Depends on D8947

Reviewers: cedric

Reviewed By: cedric

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8948
This commit is contained in:
Mike Blumenkrantz 2019-05-29 09:15:06 -04:00
parent bf7b030517
commit a8fda441be
1 changed files with 106 additions and 67 deletions

View File

@ -779,6 +779,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
int group_path_started = 0;
Evas_Object *nested_smart = NULL;
char lang[PATH_MAX];
Eina_Hash *part_match = NULL;
/* Get data pointer of top-of-stack */
int idx = eina_array_count(nested) - 1;
@ -797,6 +798,8 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
evas_event_freeze(tev);
collect = _edje_object_collect(ed);
if (collect)
part_match = eina_hash_string_superfast_new(NULL);
if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed);
@ -938,6 +941,8 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
Eina_Bool memerr = EINA_FALSE;
ep = ed->collection->parts[n];
if (part_match)
eina_hash_add(part_match, ep->name, (void*)1);
if (ep->nested_children_count) /* Add object to nested parts list */
{
@ -1592,6 +1597,38 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
{
Evas_Object *child = NULL;
if (!eina_hash_find(part_match, eud->part))
{
/* part no longer exists */
switch (eud->type)
{
case EDJE_USER_SWALLOW:
child = eud->u.swallow.child;
break;
case EDJE_USER_BOX_PACK:
child = eud->u.box.child;
break;
case EDJE_USER_TABLE_PACK:
child = eud->u.table.child;
break;
case EDJE_USER_STRING:
case EDJE_USER_DRAG_STEP:
case EDJE_USER_DRAG_PAGE:
case EDJE_USER_DRAG_VALUE:
case EDJE_USER_DRAG_SIZE:
case EDJE_USER_TEXT_STYLE:
case EDJE_USER_TEXT_EXPAND:
default:
break;
}
if (child)
{
WRN("Container part '%s' no longer exists, hiding previously-contained child object", eud->part);
evas_object_hide(child);
}
}
else
{
switch (eud->type)
{
case EDJE_USER_SWALLOW:
@ -1670,6 +1707,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
}
break;
}
}
if (eud) _edje_user_definition_remove(eud, child);
}
@ -1679,6 +1717,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
edje_object_part_box_append(obj, eud->part, eud->u.box.child);
_edje_user_definition_remove(eud, eud->u.box.child);
}
eina_hash_free(part_match);
}
if (_edje_language)
snprintf(lang, sizeof(lang), "edje,language,%s", _edje_language);