forked from enlightenment/efl
Eo: Fix issue of too many unrefs in some cases.
This problem was that because the refcount is now shared between the parent and the programmer in some cases we would get a double unref. An example way of triggering it is creating a button and putting it in a box. The box has a callback registered that when the button is deleted it would delete itself too. The problem is that the delete callback is called the button is removed from the box thus causing the box to unref it again (because of the parent), although the refcount was already accounted for. There is another more convoluted scenario that I have yet to fix. Thanks to raster for reporting.
This commit is contained in:
parent
4bae0f135a
commit
9c264fa028
|
@ -488,8 +488,9 @@ _eo_base_parent_set(Eo *obj, Eo_Base_Data *pd, Eo *parent_id)
|
||||||
pd->parent, obj);
|
pd->parent, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only unref if we don't have a new parent instead. */
|
/* Only unref if we don't have a new parent instead and we are not at
|
||||||
if (!parent_id)
|
* the process of deleting the object.*/
|
||||||
|
if (!parent_id && !eo_obj->del_triggered)
|
||||||
{
|
{
|
||||||
_eo_unref(eo_obj);
|
_eo_unref(eo_obj);
|
||||||
}
|
}
|
||||||
|
@ -1432,8 +1433,6 @@ _eo_base_destructor(Eo *obj, Eo_Base_Data *pd)
|
||||||
|
|
||||||
if (pd->parent)
|
if (pd->parent)
|
||||||
{
|
{
|
||||||
/* A bit ugly, but unparent unrefs, so we need to ref before. */
|
|
||||||
eo_ref(obj);
|
|
||||||
eo_parent_set(obj, NULL);
|
eo_parent_set(obj, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -332,8 +332,6 @@ _eo_unref(_Eo_Object *obj)
|
||||||
obj->del_triggered = EINA_TRUE;
|
obj->del_triggered = EINA_TRUE;
|
||||||
|
|
||||||
_eo_del_internal(__FILE__, __LINE__, obj);
|
_eo_del_internal(__FILE__, __LINE__, obj);
|
||||||
|
|
||||||
obj->del_triggered = EINA_FALSE;
|
|
||||||
#ifdef EO_DEBUG
|
#ifdef EO_DEBUG
|
||||||
/* If for some reason it's not empty, clear it. */
|
/* If for some reason it's not empty, clear it. */
|
||||||
while (obj->xrefs)
|
while (obj->xrefs)
|
||||||
|
|
Loading…
Reference in New Issue