forked from enlightenment/efl
vpath file - add a keey property to know if obj should be kept around
if its a file downloading (to a tmp location) or a zip/tar/whatever file being extracted also to a tmp location and that tmp file needs to be removed after ...you need to keep the obj around to know when to delete the file. this makes the keeping optional and you query if the vpath obj is meant to be kept or not. if it's not it's safe to del immediately. this cuts down 1 obj per image obj/edje obj when generally unused. save some mem.
This commit is contained in:
parent
95d83e8040
commit
76244d89a7
|
@ -395,6 +395,11 @@ _edje_object_efl_file_file_set(Eo *obj, Edje *ed, const char *file, const char *
|
||||||
file2 = efl_vpath_file_result_get(ed->file_obj);
|
file2 = efl_vpath_file_result_get(ed->file_obj);
|
||||||
|
|
||||||
f = eina_file_open(file2, EINA_FALSE);
|
f = eina_file_open(file2, EINA_FALSE);
|
||||||
|
if ((ed->file_obj) && (!efl_vpath_file_keep_get(ed->file_obj)))
|
||||||
|
{
|
||||||
|
efl_del(ed->file_obj);
|
||||||
|
ed->file_obj = NULL;
|
||||||
|
}
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
efl_del(ed->file_obj);
|
efl_del(ed->file_obj);
|
||||||
|
|
|
@ -404,6 +404,11 @@ _efl_vpath_core_efl_vpath_fetch(Eo *obj, Efl_Vpath_Core_Data *pd EINA_UNUSED, co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// XXX: handle file:// urls locally...
|
||||||
|
// XXX: if its a remote url or zip file etc. where we need to
|
||||||
|
// keep tmp file around then we need to set keep to true
|
||||||
|
// efl_vpath_file_keept_set(file, EINA_TRUE);
|
||||||
|
|
||||||
// file:/// <- local file path uri
|
// file:/// <- local file path uri
|
||||||
// file://localhost/ <- local file path uri
|
// file://localhost/ <- local file path uri
|
||||||
// file://hostname/ <- remove file path uri
|
// file://hostname/ <- remove file path uri
|
||||||
|
|
|
@ -10,6 +10,7 @@ struct _Efl_Vpath_File_Data
|
||||||
const char *path;
|
const char *path;
|
||||||
const char *result;
|
const char *result;
|
||||||
Eina_Bool called : 1;
|
Eina_Bool called : 1;
|
||||||
|
Eina_Bool keep : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
|
@ -36,6 +37,18 @@ _efl_vpath_file_result_get(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd)
|
||||||
return pd->result;
|
return pd->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_efl_vpath_file_keep_set(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd, Eina_Bool keep)
|
||||||
|
{
|
||||||
|
pd->keep = keep;
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static Eina_Bool
|
||||||
|
_efl_vpath_file_keep_get(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd)
|
||||||
|
{
|
||||||
|
return pd->keep;
|
||||||
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Bool
|
EOLIAN static Eina_Bool
|
||||||
_efl_vpath_file_do(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd)
|
_efl_vpath_file_do(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,14 @@ class Efl.Vpath.File (Efl.Object)
|
||||||
path: string; [[ The resulting destination file ]]
|
path: string; [[ The resulting destination file ]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@property keep {
|
||||||
|
[[ If this object has to be kept for the usage of the result ]]
|
||||||
|
set {}
|
||||||
|
get {}
|
||||||
|
values {
|
||||||
|
keep: bool; [[ If the object neerds tobe kept around ]]
|
||||||
|
}
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
[[ Actually begin the resolving here - emit event now or do later ]]
|
[[ Actually begin the resolving here - emit event now or do later ]]
|
||||||
return: bool; [[ Result callback already called ]]
|
return: bool; [[ Result callback already called ]]
|
||||||
|
|
|
@ -68,6 +68,8 @@ struct _Efl_Canvas_Video_Data
|
||||||
|
|
||||||
Ecore_Job *job;
|
Ecore_Job *job;
|
||||||
|
|
||||||
|
Efl_Vpath_File *file_obj;
|
||||||
|
|
||||||
const char *title;
|
const char *title;
|
||||||
|
|
||||||
#ifdef HAVE_EIO
|
#ifdef HAVE_EIO
|
||||||
|
@ -169,6 +171,11 @@ _smart_data_free(Efl_Canvas_Video_Data *sd)
|
||||||
sd->save_xattr = NULL;
|
sd->save_xattr = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (sd->file_obj)
|
||||||
|
{
|
||||||
|
efl_del(sd->file_obj);
|
||||||
|
sd->file_obj = NULL;
|
||||||
|
}
|
||||||
if (sd->engine_instance)
|
if (sd->engine_instance)
|
||||||
{
|
{
|
||||||
emotion_engine_instance_file_close(sd->engine_instance);
|
emotion_engine_instance_file_close(sd->engine_instance);
|
||||||
|
@ -374,7 +381,7 @@ _efl_canvas_video_efl_file_file_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *
|
||||||
sd->video.h = 0;
|
sd->video.h = 0;
|
||||||
if ((file) && (file[0] != 0))
|
if ((file) && (file[0] != 0))
|
||||||
{
|
{
|
||||||
const char *file2;
|
const char *file2 = NULL;
|
||||||
|
|
||||||
eina_stringshare_replace(&sd->file, file);
|
eina_stringshare_replace(&sd->file, file);
|
||||||
emotion_engine_instance_file_close(sd->engine_instance);
|
emotion_engine_instance_file_close(sd->engine_instance);
|
||||||
|
@ -383,19 +390,35 @@ _efl_canvas_video_efl_file_file_set(Eo *obj EINA_UNUSED, Efl_Canvas_Video_Data *
|
||||||
_emotion_image_data_zero(sd->obj);
|
_emotion_image_data_zero(sd->obj);
|
||||||
sd->open = 0;
|
sd->open = 0;
|
||||||
|
|
||||||
Efl_Vpath_File *file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file);
|
if (sd->file_obj)
|
||||||
efl_vpath_file_do(file_obj);
|
{
|
||||||
|
efl_del(sd->file_obj);
|
||||||
|
sd->file_obj = NULL;
|
||||||
|
}
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
sd->file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file);
|
||||||
|
efl_vpath_file_do(sd->file_obj);
|
||||||
// XXX:FIXME: allow this to be async
|
// XXX:FIXME: allow this to be async
|
||||||
efl_vpath_file_wait(file_obj);
|
efl_vpath_file_wait(sd->file_obj);
|
||||||
file2 = efl_vpath_file_result_get(file_obj);
|
file2 = efl_vpath_file_result_get(sd->file_obj);
|
||||||
|
}
|
||||||
|
|
||||||
if (!emotion_engine_instance_file_open(sd->engine_instance, file2))
|
if (!emotion_engine_instance_file_open(sd->engine_instance, file2))
|
||||||
{
|
{
|
||||||
WRN("Couldn't open file=%s", sd->file);
|
WRN("Couldn't open file=%s", sd->file);
|
||||||
efl_del(file_obj);
|
if (sd->file_obj)
|
||||||
|
{
|
||||||
|
efl_del(sd->file_obj);
|
||||||
|
sd->file_obj = NULL;
|
||||||
|
}
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
efl_del(file_obj);
|
if ((sd->file_obj) && (!efl_vpath_file_keep_get(sd->file_obj)))
|
||||||
|
{
|
||||||
|
efl_del(sd->file_obj);
|
||||||
|
sd->file_obj = NULL;
|
||||||
|
}
|
||||||
DBG("successfully opened file=%s", sd->file);
|
DBG("successfully opened file=%s", sd->file);
|
||||||
sd->pos = 0.0;
|
sd->pos = 0.0;
|
||||||
if (sd->play) emotion_engine_instance_play(sd->engine_instance, 0.0);
|
if (sd->play) emotion_engine_instance_play(sd->engine_instance, 0.0);
|
||||||
|
|
|
@ -70,6 +70,8 @@ _evas_image_file_set(Eo *eo_obj, const char *file, const char *key)
|
||||||
|
|
||||||
evas_object_async_block(obj);
|
evas_object_async_block(obj);
|
||||||
_evas_image_init_set(NULL, file, key, eo_obj, obj, o, &lo);
|
_evas_image_init_set(NULL, file, key, eo_obj, obj, o, &lo);
|
||||||
|
if (o->file_obj) efl_del(o->file_obj);
|
||||||
|
o->file_obj = NULL;
|
||||||
file2 = o->cur->u.file;
|
file2 = o->cur->u.file;
|
||||||
if (file2)
|
if (file2)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +84,11 @@ _evas_image_file_set(Eo *eo_obj, const char *file, const char *key)
|
||||||
o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, &lo);
|
o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, &lo);
|
||||||
o->buffer_data_set = EINA_FALSE;
|
o->buffer_data_set = EINA_FALSE;
|
||||||
_evas_image_done_set(eo_obj, obj, o);
|
_evas_image_done_set(eo_obj, obj, o);
|
||||||
|
if ((o->file_obj) && (!efl_vpath_file_keep_get(o->file_obj)))
|
||||||
|
{
|
||||||
|
efl_del(o->file_obj);
|
||||||
|
o->file_obj = NULL;
|
||||||
|
}
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1312,6 +1312,8 @@ _evas_image_load(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Imag
|
||||||
{
|
{
|
||||||
const char *file2 = o->cur->u.file;
|
const char *file2 = o->cur->u.file;
|
||||||
|
|
||||||
|
if (o->file_obj) efl_del(o->file_obj);
|
||||||
|
o->file_obj = NULL;
|
||||||
if (file2)
|
if (file2)
|
||||||
{
|
{
|
||||||
o->file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file2);
|
o->file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file2);
|
||||||
|
@ -1321,6 +1323,11 @@ _evas_image_load(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Imag
|
||||||
file2 = efl_vpath_file_result_get(o->file_obj);
|
file2 = efl_vpath_file_result_get(o->file_obj);
|
||||||
}
|
}
|
||||||
o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, &lo);
|
o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, &lo);
|
||||||
|
if ((o->file_obj) && (!efl_vpath_file_keep_get(o->file_obj)))
|
||||||
|
{
|
||||||
|
efl_del(o->file_obj);
|
||||||
|
o->file_obj = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o->engine_data)
|
if (o->engine_data)
|
||||||
|
|
Loading…
Reference in New Issue