summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-03-13 14:50:48 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-03-27 15:03:06 -0700
commit6b6faef3a359f453b04a3783b7e3633f3db314c6 (patch)
tree2d4b3e278f32e64b47dda8dc85b74e5897c451f7 /src/lib/eio
parenta947d8e5b1801fe5831a20c159ee3140d0ba9f25 (diff)
eio: rely on efl_future_then to properly protect Eo object during the lifecycle of the future callback.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D8334
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_model.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/eio/efl_io_model.c b/src/lib/eio/efl_io_model.c
index 44bd69d..e43c9c0 100644
--- a/src/lib/eio/efl_io_model.c
+++ b/src/lib/eio/efl_io_model.c
@@ -439,10 +439,9 @@ _eio_build_mime_clean(Efl_Io_Model_Data *pd)
439} 439}
440 440
441static Eina_Value 441static Eina_Value
442_eio_build_mime_now(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED) 442_eio_build_mime_now(Eo *model, void *data, const Eina_Value v)
443{ 443{
444 Efl_Io_Model *model = data; 444 Efl_Io_Model_Data *pd = data;
445 Efl_Io_Model_Data *pd = efl_data_scope_get(model, EFL_IO_MODEL_CLASS);
446 445
447 if (v.type == EINA_VALUE_TYPE_ERROR) goto on_error; 446 if (v.type == EINA_VALUE_TYPE_ERROR) goto on_error;
448 if (!pd->loop) goto on_error; 447 if (!pd->loop) goto on_error;
@@ -450,8 +449,9 @@ _eio_build_mime_now(void *data, const Eina_Value v, const Eina_Future *dead_futu
450 // Make sure that we are not over consuming time in the main loop 449 // Make sure that we are not over consuming time in the main loop
451 if (delayed_queue || ecore_time_get() - ecore_loop_time_get() > 0.004) 450 if (delayed_queue || ecore_time_get() - ecore_loop_time_get() > 0.004)
452 { 451 {
453 Eina_Future *f = eina_future_then(_build_delay(model), 452 Eina_Future *f = efl_future_then(model, _build_delay(model),
454 _eio_build_mime_now, model, NULL); 453 .success = _eio_build_mime_now,
454 .data = pd);
455 return eina_future_as_value(efl_future_then(model, f)); 455 return eina_future_as_value(efl_future_then(model, f));
456 } 456 }
457 457
@@ -472,16 +472,14 @@ _eio_build_mime_now(void *data, const Eina_Value v, const Eina_Future *dead_futu
472static void 472static void
473_eio_build_mime(const Efl_Object *model, Efl_Io_Model_Data *pd) 473_eio_build_mime(const Efl_Object *model, Efl_Io_Model_Data *pd)
474{ 474{
475 Eina_Future *f;
476
477 if (pd->mime_type) return ; 475 if (pd->mime_type) return ;
478 if (pd->request.mime) return ; 476 if (pd->request.mime) return ;
479 477
480 efl_wref_add(efl_loop_get(model), &pd->loop); 478 efl_wref_add(efl_loop_get(model), &pd->loop);
481 479
482 f = efl_loop_job(pd->loop); 480 pd->request.mime = efl_future_then(model, efl_loop_job(pd->loop),
483 f = eina_future_then(f, _eio_build_mime_now, model, NULL); 481 .success = _eio_build_mime_now,
484 pd->request.mime = efl_future_then(model, f); 482 .data = pd);
485} 483}
486 484
487static Eina_Value * 485static Eina_Value *