cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=218c51e6e45875b5fc8b85dfc18ce72ce2d50d12

commit 218c51e6e45875b5fc8b85dfc18ce72ce2d50d12
Author: Cedric BAIL <[email protected]>
Date:   Tue Jan 29 11:57:24 2019 -0800

    elementary: make sure Efl.Ui.Average_Model stay alive until the end of a 
property_set.
    
    Reviewed-by: SangHyeon Jade Lee <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D7863
---
 src/lib/elementary/efl_ui_average_model.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/lib/elementary/efl_ui_average_model.c 
b/src/lib/elementary/efl_ui_average_model.c
index 17f4f8937a..20e1da2c57 100644
--- a/src/lib/elementary/efl_ui_average_model.c
+++ b/src/lib/elementary/efl_ui_average_model.c
@@ -50,9 +50,11 @@ _efl_ui_average_model_update(Eo *obj EINA_UNUSED, void 
*data, const Eina_Value v
 }
 
 static void
-_efl_ui_average_model_clean(Eo *obj EINA_UNUSED, void *data, const Eina_Future 
*dead_future EINA_UNUSED)
+_efl_ui_average_model_clean(Eo *obj, void *data, const Eina_Future 
*dead_future EINA_UNUSED)
 {
    free(data);
+
+   efl_unref(obj);
 }
 
 static Eina_Future *
@@ -84,6 +86,14 @@ _efl_ui_average_model_prepare(Eo *obj,
    update->total = total;
    update->seen = seen;
 
+   // As we are operating asynchronously and we want to make sure that the 
object
+   // survive until the transaction is commited, we will ref the object here
+   // and unref on clean. This is necessary so that a nested call of 
property_set
+   // on a model returned by children_slice_get, the user doesn't have to keep 
a
+   // reference around to do the same. It shouldn't create any problem as this
+   // future would be cancelled automatically when the parent object get 
destroyed.
+   efl_ref(obj);
+
    // We have to make the change after we fetch the old value, otherwise, 
well, no old value left
    f = efl_model_property_set(efl_super(obj, EFL_UI_AVERAGE_MODEL_CLASS), 
property, value);
 

-- 


Reply via email to