Commit 6a559a6f authored by Jean-Philippe Andre's avatar Jean-Philippe Andre

eo: Prevent eo_override to be called on an already overridden object

I don't see the point of it but can't be bothered to argue.
For Tom.
parent 83301ca6
......@@ -452,6 +452,10 @@ EAPI const Eo_Class *eo_class_new(const Eo_Class_Description *desc, const Eo_Cla
*
* If @p ops is #NULL, this will revert the @p obj to its original class
* without any function overrides.
*
* It is not possible to override a function table of an object when it's
* already been overridden. Call eo_override(obj, NULL) first if you really
* need to do that.
*/
EAPI Eina_Bool eo_override(Eo *obj, const Eo_Ops *ops);
......
......@@ -1360,6 +1360,12 @@ eo_override(Eo *eo_id, const Eo_Ops *ops)
_vtable_init(obj->vtable, previous->size);
_vtable_copy_all(obj->vtable, previous);
}
else
{
ERR("Function table already overridden, not allowed to override again. "
"Call with NULL to reset the function table first.");
return EINA_FALSE;
}
if (!_eo_class_funcs_set(obj->vtable, ops, obj->klass, klass, EINA_TRUE))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment