summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-13 15:29:09 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-13 16:51:49 +0900
commit76244d89a75c0a465c3b4eb63d642b6ad14a3d74 (patch)
tree3c6a1055619f36f5e6aed8c410c3087bf421b790 /src
parent95d83e80406ddf48305cdbc91eecd340ecc4c6e1 (diff)
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.
Diffstat (limited to '')
-rw-r--r--src/lib/edje/edje_smart.c5
-rw-r--r--src/lib/efl/interfaces/efl_vpath_core.c5
-rw-r--r--src/lib/efl/interfaces/efl_vpath_file.c13
-rw-r--r--src/lib/efl/interfaces/efl_vpath_file.eo8
-rw-r--r--src/lib/emotion/emotion_smart.c39
-rw-r--r--src/lib/evas/canvas/efl_canvas_image.c8
-rw-r--r--src/lib/evas/canvas/evas_object_image.c7
7 files changed, 76 insertions, 9 deletions
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index b769f59dd8..583e714310 100644
--- a/src/lib/edje/edje_smart.c
+++ b/src/lib/edje/edje_smart.c
@@ -395,6 +395,11 @@ _edje_object_efl_file_file_set(Eo *obj, Edje *ed, const char *file, const char *
395 file2 = efl_vpath_file_result_get(ed->file_obj); 395 file2 = efl_vpath_file_result_get(ed->file_obj);
396 396
397 f = eina_file_open(file2, EINA_FALSE); 397 f = eina_file_open(file2, EINA_FALSE);
398 if ((ed->file_obj) && (!efl_vpath_file_keep_get(ed->file_obj)))
399 {
400 efl_del(ed->file_obj);
401 ed->file_obj = NULL;
402 }
398 if (!f) 403 if (!f)
399 { 404 {
400 efl_del(ed->file_obj); 405 efl_del(ed->file_obj);
diff --git a/src/lib/efl/interfaces/efl_vpath_core.c b/src/lib/efl/interfaces/efl_vpath_core.c
index 0e343782cd..f3bff42323 100644
--- a/src/lib/efl/interfaces/efl_vpath_core.c
+++ b/src/lib/efl/interfaces/efl_vpath_core.c
@@ -404,6 +404,11 @@ _efl_vpath_core_efl_vpath_fetch(Eo *obj, Efl_Vpath_Core_Data *pd EINA_UNUSED, co
404 } 404 }
405 } 405 }
406 } 406 }
407 // XXX: handle file:// urls locally...
408 // XXX: if its a remote url or zip file etc. where we need to
409 // keep tmp file around then we need to set keep to true
410 // efl_vpath_file_keept_set(file, EINA_TRUE);
411
407 // file:/// <- local file path uri 412 // file:/// <- local file path uri
408 // file://localhost/ <- local file path uri 413 // file://localhost/ <- local file path uri
409 // file://hostname/ <- remove file path uri 414 // file://hostname/ <- remove file path uri
diff --git a/src/lib/efl/interfaces/efl_vpath_file.c b/src/lib/efl/interfaces/efl_vpath_file.c
index 37613fca11..3e098828ed 100644
--- a/src/lib/efl/interfaces/efl_vpath_file.c
+++ b/src/lib/efl/interfaces/efl_vpath_file.c
@@ -10,6 +10,7 @@ struct _Efl_Vpath_File_Data
10 const char *path; 10 const char *path;
11 const char *result; 11 const char *result;
12 Eina_Bool called : 1; 12 Eina_Bool called : 1;
13 Eina_Bool keep : 1;
13}; 14};
14 15
15EOLIAN static void 16EOLIAN static void
@@ -36,6 +37,18 @@ _efl_vpath_file_result_get(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd)
36 return pd->result; 37 return pd->result;
37} 38}
38 39
40EOLIAN static void
41_efl_vpath_file_keep_set(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd, Eina_Bool keep)
42{
43 pd->keep = keep;
44}
45
46EOLIAN static Eina_Bool
47_efl_vpath_file_keep_get(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd)
48{
49 return pd->keep;
50}
51
39EOLIAN static Eina_Bool 52EOLIAN static Eina_Bool
40_efl_vpath_file_do(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd) 53_efl_vpath_file_do(Eo *obj EINA_UNUSED, Efl_Vpath_File_Data *pd)
41{ 54{
diff --git a/src/lib/efl/interfaces/efl_vpath_file.eo b/src/lib/efl/interfaces/efl_vpath_file.eo
index e061a78bf3..1568a3ea9c 100644
--- a/src/lib/efl/interfaces/efl_vpath_file.eo
+++ b/src/lib/efl/interfaces/efl_vpath_file.eo
@@ -32,6 +32,14 @@ class Efl.Vpath.File (Efl.Object)
32 path: string; [[ The resulting destination file ]] 32 path: string; [[ The resulting destination file ]]
33 } 33 }
34 } 34 }
35 @property keep {
36 [[ If this object has to be kept for the usage of the result ]]
37 set {}
38 get {}
39 values {
40 keep: bool; [[ If the object neerds tobe kept around ]]
41 }
42 }
35 do { 43 do {
36 [[ Actually begin the resolving here - emit event now or do later ]] 44 [[ Actually begin the resolving here - emit event now or do later ]]
37 return: bool; [[ Result callback already called ]] 45 return: bool; [[ Result callback already called ]]
diff --git a/src/lib/emotion/emotion_smart.c b/src/lib/emotion/emotion_smart.c
index 93cf1975ff..96f14da295 100644
--- a/src/lib/emotion/emotion_smart.c
+++ b/src/lib/emotion/emotion_smart.c
@@ -68,6 +68,8 @@ struct _Efl_Canvas_Video_Data
68 68
69 Ecore_Job *job; 69 Ecore_Job *job;
70 70
71 Efl_Vpath_File *file_obj;
72
71 const char *title; 73 const char *title;
72 74
73#ifdef HAVE_EIO 75#ifdef HAVE_EIO
@@ -169,6 +171,11 @@ _smart_data_free(Efl_Canvas_Video_Data *sd)
169 sd->save_xattr = NULL; 171 sd->save_xattr = NULL;
170#endif 172#endif
171 173
174 if (sd->file_obj)
175 {
176 efl_del(sd->file_obj);
177 sd->file_obj = NULL;
178 }
172 if (sd->engine_instance) 179 if (sd->engine_instance)
173 { 180 {
174 emotion_engine_instance_file_close(sd->engine_instance); 181 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 *
374 sd->video.h = 0; 381 sd->video.h = 0;
375 if ((file) && (file[0] != 0)) 382 if ((file) && (file[0] != 0))
376 { 383 {
377 const char *file2; 384 const char *file2 = NULL;
378 385
379 eina_stringshare_replace(&sd->file, file); 386 eina_stringshare_replace(&sd->file, file);
380 emotion_engine_instance_file_close(sd->engine_instance); 387 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 *
383 _emotion_image_data_zero(sd->obj); 390 _emotion_image_data_zero(sd->obj);
384 sd->open = 0; 391 sd->open = 0;
385 392
386 Efl_Vpath_File *file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file); 393 if (sd->file_obj)
387 efl_vpath_file_do(file_obj); 394 {
388 // XXX:FIXME: allow this to be async 395 efl_del(sd->file_obj);
389 efl_vpath_file_wait(file_obj); 396 sd->file_obj = NULL;
390 file2 = efl_vpath_file_result_get(file_obj); 397 }
398 if (file)
399 {
400 sd->file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file);
401 efl_vpath_file_do(sd->file_obj);
402 // XXX:FIXME: allow this to be async
403 efl_vpath_file_wait(sd->file_obj);
404 file2 = efl_vpath_file_result_get(sd->file_obj);
405 }
391 406
392 if (!emotion_engine_instance_file_open(sd->engine_instance, file2)) 407 if (!emotion_engine_instance_file_open(sd->engine_instance, file2))
393 { 408 {
394 WRN("Couldn't open file=%s", sd->file); 409 WRN("Couldn't open file=%s", sd->file);
395 efl_del(file_obj); 410 if (sd->file_obj)
411 {
412 efl_del(sd->file_obj);
413 sd->file_obj = NULL;
414 }
396 return EINA_FALSE; 415 return EINA_FALSE;
397 } 416 }
398 efl_del(file_obj); 417 if ((sd->file_obj) && (!efl_vpath_file_keep_get(sd->file_obj)))
418 {
419 efl_del(sd->file_obj);
420 sd->file_obj = NULL;
421 }
399 DBG("successfully opened file=%s", sd->file); 422 DBG("successfully opened file=%s", sd->file);
400 sd->pos = 0.0; 423 sd->pos = 0.0;
401 if (sd->play) emotion_engine_instance_play(sd->engine_instance, 0.0); 424 if (sd->play) emotion_engine_instance_play(sd->engine_instance, 0.0);
diff --git a/src/lib/evas/canvas/efl_canvas_image.c b/src/lib/evas/canvas/efl_canvas_image.c
index 3ebb2c92d9..b03808e005 100644
--- a/src/lib/evas/canvas/efl_canvas_image.c
+++ b/src/lib/evas/canvas/efl_canvas_image.c
@@ -70,6 +70,8 @@ _evas_image_file_set(Eo *eo_obj, const char *file, const char *key)
70 70
71 evas_object_async_block(obj); 71 evas_object_async_block(obj);
72 _evas_image_init_set(NULL, file, key, eo_obj, obj, o, &lo); 72 _evas_image_init_set(NULL, file, key, eo_obj, obj, o, &lo);
73 if (o->file_obj) efl_del(o->file_obj);
74 o->file_obj = NULL;
73 file2 = o->cur->u.file; 75 file2 = o->cur->u.file;
74 if (file2) 76 if (file2)
75 { 77 {
@@ -82,7 +84,11 @@ _evas_image_file_set(Eo *eo_obj, const char *file, const char *key)
82 o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, &lo); 84 o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, &lo);
83 o->buffer_data_set = EINA_FALSE; 85 o->buffer_data_set = EINA_FALSE;
84 _evas_image_done_set(eo_obj, obj, o); 86 _evas_image_done_set(eo_obj, obj, o);
85 87 if ((o->file_obj) && (!efl_vpath_file_keep_get(o->file_obj)))
88 {
89 efl_del(o->file_obj);
90 o->file_obj = NULL;
91 }
86 return EINA_TRUE; 92 return EINA_TRUE;
87} 93}
88 94
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index fb878c030d..641e8a4e28 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -1312,6 +1312,8 @@ _evas_image_load(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Imag
1312 { 1312 {
1313 const char *file2 = o->cur->u.file; 1313 const char *file2 = o->cur->u.file;
1314 1314
1315 if (o->file_obj) efl_del(o->file_obj);
1316 o->file_obj = NULL;
1315 if (file2) 1317 if (file2)
1316 { 1318 {
1317 o->file_obj = efl_vpath_manager_fetch(EFL_VPATH_MANAGER_CLASS, file2); 1319 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
1321 file2 = efl_vpath_file_result_get(o->file_obj); 1323 file2 = efl_vpath_file_result_get(o->file_obj);
1322 } 1324 }
1323 o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, &lo); 1325 o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, &lo);
1326 if ((o->file_obj) && (!efl_vpath_file_keep_get(o->file_obj)))
1327 {
1328 efl_del(o->file_obj);
1329 o->file_obj = NULL;
1330 }
1324 } 1331 }
1325 1332
1326 if (o->engine_data) 1333 if (o->engine_data)