forked from enlightenment/efl
Eobj: Fixed wref bugs and improve it's tests.
SVN revision: 70584
This commit is contained in:
parent
e1efeae7a4
commit
18eda16fa2
|
@ -164,13 +164,13 @@ _wref_del(const Eo *obj, const void *class_data, va_list *list)
|
|||
if (!pd->wrefs)
|
||||
{
|
||||
ERR("There are no weak refs for object %p", obj);
|
||||
*wref = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Move the last item in the array instead of the current wref. */
|
||||
count = _wref_count(pd);
|
||||
|
||||
if (count > 1)
|
||||
{
|
||||
Eo ***itr;
|
||||
for (itr = pd->wrefs ; *itr ; itr++)
|
||||
|
@ -182,9 +182,19 @@ _wref_del(const Eo *obj, const void *class_data, va_list *list)
|
|||
}
|
||||
}
|
||||
|
||||
if (!*itr)
|
||||
{
|
||||
ERR("Wref %p is not associated with object %p", wref, obj);
|
||||
*wref = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 1)
|
||||
{
|
||||
// No count--; because of the NULL that is not included in the count. */
|
||||
pd->wrefs = realloc(pd->wrefs, sizeof(*pd->wrefs) * count);
|
||||
pd->wrefs[count] = NULL;
|
||||
pd->wrefs[count - 1] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -70,7 +70,7 @@ START_TEST(eo_weak_reference)
|
|||
|
||||
Eo *obj = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *obj2 = eo_add(SIMPLE_CLASS, NULL);
|
||||
Eo *wref;
|
||||
Eo *wref, *wref2, *wref3;
|
||||
eo_do(obj, eo_wref_add(&wref));
|
||||
fail_if(!wref);
|
||||
|
||||
|
@ -103,7 +103,23 @@ START_TEST(eo_weak_reference)
|
|||
|
||||
wref = obj;
|
||||
eo_do(obj, eo_wref_del(&wref));
|
||||
fail_if(wref != obj);
|
||||
fail_if(wref);
|
||||
|
||||
wref = wref2 = wref3 = NULL;
|
||||
eo_do(obj, eo_wref_add(&wref), eo_wref_add(&wref2), eo_wref_add(&wref3));
|
||||
fail_if(!wref);
|
||||
fail_if(!wref2);
|
||||
fail_if(!wref3);
|
||||
eo_do(obj, eo_wref_del(&wref), eo_wref_del(&wref2), eo_wref_del(&wref3));
|
||||
fail_if(wref);
|
||||
fail_if(wref2);
|
||||
fail_if(wref3);
|
||||
|
||||
eo_do(obj, eo_wref_add(&wref2), eo_wref_add(&wref3));
|
||||
wref = obj;
|
||||
eo_do(obj, eo_wref_del(&wref));
|
||||
fail_if(wref);
|
||||
eo_do(obj, eo_wref_del(&wref2), eo_wref_del(&wref3));
|
||||
|
||||
eo_unref(obj);
|
||||
eo_unref(obj2);
|
||||
|
|
Loading…
Reference in New Issue