From 54894824847c69b1acaa0a4382de6e39bf83a66b Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 11 Sep 2019 13:38:21 -0400 Subject: [PATCH] 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 --- src/lib/edje/edje_smart.c | 12 +----------- src/lib/efl/interfaces/efl_file.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c index 674c7cd514..4801432ebc 100644 --- a/src/lib/edje/edje_smart.c +++ b/src/lib/edje/edje_smart.c @@ -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); } diff --git a/src/lib/efl/interfaces/efl_file.c b/src/lib/efl/interfaces/efl_file.c index 846c88b9db..d6f262d3e2 100644 --- a/src/lib/efl/interfaces/efl_file.c +++ b/src/lib/efl/interfaces/efl_file.c @@ -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);