Hi,
I've been working with evas_object_image_preload and have some issues
with it. When I try to preload an image and then I try to preload that
same image again from another image object, the second one doesn't
receive a preloaded_callback.
Attached is a patch that fixes this problem to me. It makes the
"target" attribute from image entry become a list, and then sends the
preloaded signal to all targets in the list.
--
Rafael Antognolli
ProFUSION embedded systems
http://profusion.mobi
Index: src/lib/cache/evas_cache_image.c
===================================================================
--- src/lib/cache/evas_cache_image.c (revision 38552)
+++ src/lib/cache/evas_cache_image.c (working copy)
@@ -27,6 +27,12 @@
Image_Entry *ie;
};
+struct _target_list
+{
+ EINA_INLIST;
+ void *target;
+};
+
static Eina_Inlist *preload = NULL;
static Image_Entry *current = NULL;
@@ -234,6 +240,7 @@
#ifdef BUILD_ASYNC_PRELOAD
pthread_mutex_init(&ie->lock, NULL);
+ ie->targets = NULL;
#endif
if (lo)
@@ -303,8 +310,13 @@
const void *target)
{
int ret = 0;
+ struct _target_list *l;
+ l = malloc(sizeof(*l));
+ l->target = target;
+
pthread_mutex_lock(&mutex);
+ ie->targets = eina_inlist_append(ie->targets, EINA_INLIST_GET(l));
if (!ie->flags.preload)
{
@@ -312,7 +324,6 @@
t->ie = ie;
preload = eina_inlist_append(preload, EINA_INLIST_GET(t));
ie->flags.preload = 1;
- ie->target = target;
if (!running)
{
@@ -928,8 +939,20 @@
#ifdef BUILD_ASYNC_PRELOAD
if (preload)
- evas_async_events_put(im->target, EVAS_CALLBACK_IMAGE_PRELOADED, NULL,
- (void (*)(void*, Evas_Callback_Type, void*))evas_object_event_callback_call);
+ {
+ pthread_mutex_lock(&mutex);
+ while (im->targets)
+ {
+ Eina_Inlist *t = im->targets;
+ void *target = ((struct _target_list *)current->targets)->target;
+
+ im->targets = eina_inlist_remove(im->targets, im->targets);
+ free(t);
+ evas_async_events_put(target, EVAS_CALLBACK_IMAGE_PRELOADED, NULL,
+ (void (*)(void*, Evas_Callback_Type, void*))evas_object_event_callback_call);
+ }
+ pthread_mutex_unlock(&mutex);
+ }
#endif
if (error)
@@ -1134,9 +1157,21 @@
current->flags.preload = 0;
pthread_mutex_unlock(¤t->lock);
- evas_async_events_put(current->target, EVAS_CALLBACK_IMAGE_PRELOADED, NULL,
- (void (*)(void*, Evas_Callback_Type, void*))evas_object_event_callback_call);
+ pthread_mutex_lock(&mutex);
+ while (current->targets)
+ {
+ Eina_Inlist *t = current->targets;
+ void *target = ((struct _target_list *)current->targets)->target;
+ current->targets = eina_inlist_remove(current->targets,
+ current->targets);
+ free(t);
+ evas_async_events_put(target, EVAS_CALLBACK_IMAGE_PRELOADED,
+ NULL,
+ (void (*)(void*, Evas_Callback_Type,
+ void*))evas_object_event_callback_call);
+ }
+ pthread_mutex_unlock(&mutex);
current = NULL;
}
Index: src/lib/include/evas_common.h
===================================================================
--- src/lib/include/evas_common.h (revision 38552)
+++ src/lib/include/evas_common.h (working copy)
@@ -279,7 +279,7 @@
const char *file;
const char *key;
- const void *target;
+ Eina_Inlist *targets;
time_t timestamp;
time_t laststat;
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel