From a1c4588d645e7e8c787463a4ec1ffdbb5ff61eb1 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 13 Oct 2010 10:59:33 +0000 Subject: [PATCH] * eio: fix use of ecore_thread_*run. SVN revision: 53348 --- legacy/eio/src/lib/eio_single.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/legacy/eio/src/lib/eio_single.c b/legacy/eio/src/lib/eio_single.c index c3310778a8..76fb97b129 100644 --- a/legacy/eio/src/lib/eio_single.c +++ b/legacy/eio/src/lib/eio_single.c @@ -45,20 +45,25 @@ eio_long_file_set(Eio_File *common, Ecore_Cb end_cb, Ecore_Cb cancel_cb) { + Ecore_Thread *thread; + common->done_cb = done_cb; common->error_cb = error_cb; common->data = data; common->error = 0; common->thread = NULL; - /* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. */ - common->thread = ecore_thread_feedback_run(heavy_cb, - notify_cb, - end_cb, - cancel_cb, - common, - EINA_TRUE); - return !!common->thread; + /* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. + This means that common would be destroyed if thread == NULL. + */ + thread = ecore_thread_feedback_run(heavy_cb, + notify_cb, + end_cb, + cancel_cb, + common, + EINA_TRUE); + if (thread) common->thread = thread; + return !!thread; } Eina_Bool @@ -70,15 +75,21 @@ eio_file_set(Eio_File *common, Ecore_Cb end_cb, Ecore_Cb cancel_cb) { + Ecore_Thread *thread; + common->done_cb = done_cb; common->error_cb = error_cb; common->data = data; common->error = 0; common->thread = NULL; - /* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. */ - common->thread = ecore_thread_run(job_cb, end_cb, cancel_cb, common); - return !!common->thread; + /* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. + This means that common would be destroyed if thread == NULL. + */ + thread = ecore_thread_run(job_cb, end_cb, cancel_cb, common); + + if (thread) common->thread = thread; + return !!thread; } /* --- */