summaryrefslogtreecommitdiff
path: root/src/lib/eo
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-07-16 15:29:56 +0200
committerCedric BAIL <cedric.bail@free.fr>2019-07-19 10:54:57 -0700
commita0952b0c01594e34f74a959d5dc4e8d54ab847c9 (patch)
treea26842ad1ac4e6d35c0ae6c3f953cfcfca935aa1 /src/lib/eo
parente663b9da5521ad962d18d20e8def48c3e4bd786b (diff)
eo: add helper for checking the ownable state
if a object is ownable, then there is one free reference. If not, a error will be printed. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9332
Diffstat (limited to 'src/lib/eo')
-rw-r--r--src/lib/eo/Eo.h10
-rw-r--r--src/lib/eo/eo.c14
2 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index ddbad15de2..34c8a8c4b2 100644
--- a/src/lib/eo/Eo.h
+++ b/src/lib/eo/Eo.h
@@ -2318,6 +2318,7 @@ efl_alive_get(const Eo *obj)
2318{ 2318{
2319 return efl_finalized_get(obj) && !efl_invalidating_get(obj) && !efl_invalidated_get(obj); 2319 return efl_finalized_get(obj) && !efl_invalidating_get(obj) && !efl_invalidated_get(obj);
2320} 2320}
2321
2321#endif /* EFL_BETA_API_SUPPORT */ 2322#endif /* EFL_BETA_API_SUPPORT */
2322 2323
2323/** 2324/**
@@ -2360,6 +2361,15 @@ EAPI Eina_Iterator *eo_classes_iterator_new(void);
2360EAPI Eina_Iterator *eo_objects_iterator_new(void); 2361EAPI Eina_Iterator *eo_objects_iterator_new(void);
2361 2362
2362/** 2363/**
2364 * @brief Check if a object can be owned
2365 *
2366 * This API checks if the passed object has at least one free reference that is not taken by the parent relation.
2367 * If this is not the case, a ERR will be printed.
2368 *
2369 * @return EINA_TRUE if the object is ownable. EINA_FALSE if not.
2370 */
2371EAPI Eina_Bool efl_ownable_get(const Eo *obj);
2372/**
2363 * @} 2373 * @}
2364 */ 2374 */
2365 2375
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index c1156ec386..e2aed3c1ef 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -3718,3 +3718,17 @@ efl_class_type_get(const Efl_Class *klass_id)
3718 3718
3719 return klass->desc->type; 3719 return klass->desc->type;
3720} 3720}
3721
3722
3723EAPI Eina_Bool
3724efl_ownable_get(const Eo *obj)
3725{
3726 int ref = efl_ref_count(obj);
3727
3728 if (efl_parent_get(obj))
3729 ref --;
3730
3731 if (ref <= 0)
3732 ERR("There is no free reference to pass this object. Please check that this object is really owned by you.");
3733 return (ref > 0);
3734}