elementary: make sure Efl.Ui.Average_Model stay alive until the end of a property_set.

Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D7863
This commit is contained in:
Cedric BAIL 2019-01-29 11:57:24 -08:00
parent 83be87e4a4
commit 218c51e6e4
1 changed files with 11 additions and 1 deletions

View File

@ -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);