summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-03-15 16:55:07 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-03-27 15:03:26 -0700
commit4d1620f3f0ac8590f4e3c297e0e31b98313eb8ec (patch)
tree98f5fe0f6088df2cd8bd1d7be2838e12040d92eb /src/lib/eio
parent3bbaf71b68060078bc229c9c2949202e849e986e (diff)
eio: remove unecessary use of weak reference.
There is no point in keeping a pointer to the main loop now that we are using efl_future_then. This resolve potential bug with leftover dangling weak reference as efl_future_then do require a free case otherwise. Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D8374
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_model.c22
-rw-r--r--src/lib/eio/efl_io_model_private.h1
2 files changed, 1 insertions, 22 deletions
diff --git a/src/lib/eio/efl_io_model.c b/src/lib/eio/efl_io_model.c
index e2b3697..44c215e 100644
--- a/src/lib/eio/efl_io_model.c
+++ b/src/lib/eio/efl_io_model.c
@@ -434,22 +434,11 @@ _build_delay(Efl_Io_Model *model)
434 .data = eina_list_last(delayed_queue)); 434 .data = eina_list_last(delayed_queue));
435} 435}
436 436
437static void
438_eio_build_mime_clean(Efl_Io_Model_Data *pd)
439{
440 efl_wref_del(pd->loop, &pd->loop);
441 pd->loop = NULL;
442 pd->request.mime = NULL;
443}
444
445static Eina_Value 437static Eina_Value
446_eio_build_mime_now(Eo *model, void *data, const Eina_Value v) 438_eio_build_mime_now(Eo *model, void *data, const Eina_Value v)
447{ 439{
448 Efl_Io_Model_Data *pd = data; 440 Efl_Io_Model_Data *pd = data;
449 441
450 if (v.type == EINA_VALUE_TYPE_ERROR) goto on_error;
451 if (!pd->loop) goto on_error;
452
453 // Make sure that we are not over consuming time in the main loop 442 // Make sure that we are not over consuming time in the main loop
454 if (!delayed_one && 443 if (!delayed_one &&
455 (delayed_queue || ecore_time_get() - ecore_loop_time_get() > 0.004)) 444 (delayed_queue || ecore_time_get() - ecore_loop_time_get() > 0.004))
@@ -462,17 +451,10 @@ _eio_build_mime_now(Eo *model, void *data, const Eina_Value v)
462 451
463 pd->mime_type = efreet_mime_type_get(pd->path); 452 pd->mime_type = efreet_mime_type_get(pd->path);
464 453
465 _eio_build_mime_clean(pd);
466
467 efl_model_properties_changed(model, "mime_type"); 454 efl_model_properties_changed(model, "mime_type");
468 delayed_one = EINA_TRUE; 455 delayed_one = EINA_TRUE;
469 456
470 return v; 457 return v;
471
472 on_error:
473 _eio_build_mime_clean(pd);
474
475 return v;
476} 458}
477 459
478static void 460static void
@@ -481,9 +463,7 @@ _eio_build_mime(const Efl_Object *model, Efl_Io_Model_Data *pd)
481 if (pd->mime_type) return ; 463 if (pd->mime_type) return ;
482 if (pd->request.mime) return ; 464 if (pd->request.mime) return ;
483 465
484 efl_wref_add(efl_loop_get(model), &pd->loop); 466 pd->request.mime = efl_future_then(model, efl_loop_job(efl_loop_get(model)),
485
486 pd->request.mime = efl_future_then(model, efl_loop_job(pd->loop),
487 .success = _eio_build_mime_now, 467 .success = _eio_build_mime_now,
488 .data = pd); 468 .data = pd);
489} 469}
diff --git a/src/lib/eio/efl_io_model_private.h b/src/lib/eio/efl_io_model_private.h
index 8102406..2574ade 100644
--- a/src/lib/eio/efl_io_model_private.h
+++ b/src/lib/eio/efl_io_model_private.h
@@ -35,7 +35,6 @@ struct _Efl_Io_Model_Info
35 35
36struct _Efl_Io_Model_Data 36struct _Efl_Io_Model_Data
37{ 37{
38 Efl_Loop *loop;
39 Efl_Io_Model *self; 38 Efl_Io_Model *self;
40 39
41 Eina_Stringshare *path; 40 Eina_Stringshare *path;