efl: check file's mtime in efl.file::file_set to determine if file is the same

Summary:
historically, if the mtime of an edj file changes after being loaded,
the edje file should be reloaded. this needs to occur in a single call
with the previous user definitions intact, so verify that the mtime is
the same in efl.file::file_set when using the same file name

@fix

Reviewers: cedric

Reviewed By: cedric

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9877
This commit is contained in:
Mike Blumenkrantz 2019-09-11 13:38:21 -04:00
parent 7f691b47fb
commit 5489482484
2 changed files with 12 additions and 12 deletions

View File

@ -466,17 +466,7 @@ edje_object_mmap_set(Edje_Object *obj, const Eina_File *file, const char *group)
EAPI Eina_Bool
edje_object_file_set(Edje_Object *obj, const char *file, const char *group)
{
// We can't blindly unload here - this loses swallowed content (in
// swallows, boxes, tables etc.) ... this here along with an actual
// implementation of file unload broke the pager in E for starters
// as shading then unshading (double click titlebar) a window would
// lose the mini preview image obj swallowed in. also fullscreening
// would do it. this also broke gadget bar, the xkb gadget in it too
// and more... so this is a particularly bad thing break. we need to
// iterate over every child and re-swallow, re-pack into boxes, tables
// etc. because that is what edje used to do. unloading here is definitely
// worse ... so disable for now.
// efl_file_unload(obj);
/* mtime checking of file is handled in efl.file mixin */
return efl_file_simple_load(obj, file, group);
}

View File

@ -10,6 +10,7 @@ struct _Efl_File_Data
Eina_Stringshare *vpath; /* efl_file_set */
Eina_Stringshare *key; /* efl_file_key_set */
Eina_File *file; /* efl_file_mmap_set */
time_t mtime;
Eina_Bool file_opened : 1; /* if `file` was opened implicitly during load */
Eina_Bool setting : 1; /* set when this file is internally calling methods to avoid infinite recursion */
Eina_Bool loaded : 1; /* whether the currently set file properties have been loaded */
@ -91,6 +92,7 @@ _efl_file_file_set(Eo *obj, Efl_File_Data *pd, const char *file)
char *tmp;
Eina_Error err = 0;
Eina_Bool same;
struct stat st;
tmp = (char*)(file);
if (tmp)
@ -98,9 +100,17 @@ _efl_file_file_set(Eo *obj, Efl_File_Data *pd, const char *file)
same = !eina_stringshare_replace(&pd->vpath, tmp ?: file);
free(tmp);
if (file)
{
err = stat(pd->vpath, &st);
if (same && (!err)) same = st.st_mtime == pd->mtime;
}
if (same) return err;
pd->mtime = file && (!err) ? st.st_mtime : 0;
pd->loaded = EINA_FALSE;
if (!pd->setting)
if (pd->setting)
err = 0; /* this is from mmap_set, which may provide a virtual file */
else
{
pd->setting = 1;
err = efl_file_mmap_set(obj, NULL);