forked from enlightenment/efl
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
This commit is contained in:
parent
e663b9da55
commit
a0952b0c01
|
@ -2318,6 +2318,7 @@ efl_alive_get(const Eo *obj)
|
|||
{
|
||||
return efl_finalized_get(obj) && !efl_invalidating_get(obj) && !efl_invalidated_get(obj);
|
||||
}
|
||||
|
||||
#endif /* EFL_BETA_API_SUPPORT */
|
||||
|
||||
/**
|
||||
|
@ -2359,6 +2360,15 @@ EAPI Eina_Iterator *eo_classes_iterator_new(void);
|
|||
*/
|
||||
EAPI Eina_Iterator *eo_objects_iterator_new(void);
|
||||
|
||||
/**
|
||||
* @brief Check if a object can be owned
|
||||
*
|
||||
* This API checks if the passed object has at least one free reference that is not taken by the parent relation.
|
||||
* If this is not the case, a ERR will be printed.
|
||||
*
|
||||
* @return EINA_TRUE if the object is ownable. EINA_FALSE if not.
|
||||
*/
|
||||
EAPI Eina_Bool efl_ownable_get(const Eo *obj);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -3718,3 +3718,17 @@ efl_class_type_get(const Efl_Class *klass_id)
|
|||
|
||||
return klass->desc->type;
|
||||
}
|
||||
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_ownable_get(const Eo *obj)
|
||||
{
|
||||
int ref = efl_ref_count(obj);
|
||||
|
||||
if (efl_parent_get(obj))
|
||||
ref --;
|
||||
|
||||
if (ref <= 0)
|
||||
ERR("There is no free reference to pass this object. Please check that this object is really owned by you.");
|
||||
return (ref > 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue