summaryrefslogtreecommitdiff
path: root/src/lib/eio/eio_model.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-05-05 21:15:55 -0700
committerCedric BAIL <cedric@osg.samsung.com>2018-05-05 21:15:55 -0700
commite8df3515d7c198ccfbf3a1ef698d97c8b6002b1a (patch)
tree971da78359dcf5de1fa31935d56efa40e94bec4f /src/lib/eio/eio_model.c
parent382079bccd5c54c3041df25b6555f46cd502c4fc (diff)
eio: on error/cancel properly destroy weak reference.
Diffstat (limited to 'src/lib/eio/eio_model.c')
-rw-r--r--src/lib/eio/eio_model.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/eio/eio_model.c b/src/lib/eio/eio_model.c
index b8e8ebf..7275443 100644
--- a/src/lib/eio/eio_model.c
+++ b/src/lib/eio/eio_model.c
@@ -395,15 +395,22 @@ _build_delay(Efl_Loop *loop)
395 return eina_future_new(p); 395 return eina_future_new(p);
396} 396}
397 397
398static void
399_eio_build_mime_clean(Eio_Model_Data *pd)
400{
401 efl_wref_del(pd->loop, &pd->loop);
402 pd->loop = NULL;
403 pd->request.mime = NULL;
404}
405
398static Eina_Value 406static Eina_Value
399_eio_build_mime_now(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED) 407_eio_build_mime_now(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED)
400{ 408{
401 Eio_Model *model = data; 409 Eio_Model *model = data;
402 Eio_Model_Data *pd = efl_data_scope_get(model, EIO_MODEL_CLASS); 410 Eio_Model_Data *pd = efl_data_scope_get(model, EIO_MODEL_CLASS);
403 411
404 if (v.type == EINA_VALUE_TYPE_ERROR) return v; 412 if (v.type == EINA_VALUE_TYPE_ERROR) goto on_error;
405 413 if (!pd->loop) goto on_error;
406 if (!pd->loop) return v;
407 414
408 // Make sure that we are not over consuming time in the main loop 415 // Make sure that we are not over consuming time in the main loop
409 if (delayed_queue || ecore_time_get() - ecore_loop_time_get() > 0.004) 416 if (delayed_queue || ecore_time_get() - ecore_loop_time_get() > 0.004)
@@ -415,13 +422,16 @@ _eio_build_mime_now(void *data, const Eina_Value v, const Eina_Future *dead_futu
415 422
416 pd->mime_type = efreet_mime_type_get(pd->path); 423 pd->mime_type = efreet_mime_type_get(pd->path);
417 424
418 efl_wref_del(pd->loop, &pd->loop); 425 _eio_build_mime_clean(pd);
419 pd->loop = NULL;
420 pd->request.mime = NULL;
421 426
422 efl_model_properties_changed(model, "mime_type"); 427 efl_model_properties_changed(model, "mime_type");
423 428
424 return v; 429 return v;
430
431 on_error:
432 _eio_build_mime_clean(pd);
433
434 return v;
425} 435}
426 436
427static void 437static void