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
{
return efl_finalized_get(obj) && !efl_invalidating_get(obj) && !efl_invalidated_get(obj);
}
+
#endif /* EFL_BETA_API_SUPPORT */
/**
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);
+/**
* @}
*/
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);
+}