Use the old association policy to determine whether to release an object

This commit has been augmented to address the comments in
https://github.com/Microsoft/libobjc2/commit/df7f9061670cce994730d1720150adc
main
Dustin L. Howett 10 years ago committed by Dustin Howett
parent 14889c540f
commit e3b069cedc

@ -166,12 +166,17 @@ static void setReference(struct reference_list *list,
lock = lock_for_pointer(r);
lock_spinlock(lock);
}
r->policy = policy;
id old = r->object;
r->object = obj;
if (OBJC_ASSOCIATION_ASSIGN != r->policy)
@try
{
objc_release(old);
if (OBJC_ASSOCIATION_ASSIGN != r->policy)
{
objc_release(r->object);
}
}
@finally
{
r->policy = policy;
r->object = obj;
}
if (needLock)
{

Loading…
Cancel
Save