diff --git a/ChangeLog b/ChangeLog index ff7fca29a..5dfd052e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-03-04 Richard Frith-Macdonald + + * Source/NSOperation.m: retain operation while finishing so that it + doesn't get deallocated too soon (when the queue removes it). + 2011-03-04 Richard Frith-Macdonald * Source/NSNumberFormatter.m: Fix -setAllowsFloats to only operate diff --git a/Source/NSOperation.m b/Source/NSOperation.m index b0d22a4e1..b6cac47e4 100644 --- a/Source/NSOperation.m +++ b/Source/NSOperation.m @@ -458,18 +458,7 @@ static NSArray *empty = nil; } NS_ENDHANDLER; - [internal->lock lock]; - NS_DURING - { - [self _finish]; - } - NS_HANDLER - { - [internal->lock unlock]; - [localException raise]; - } - NS_ENDHANDLER - [internal->lock unlock]; + [self _finish]; [pool release]; } @@ -513,6 +502,10 @@ static NSArray *empty = nil; @implementation NSOperation (Private) - (void) _finish { + /* retain while finishing so that we don't get deallocated when our + * queue removes and releases us. + */ + [self retain]; [internal->lock lock]; if (NO == internal->finished) { @@ -533,6 +526,7 @@ static NSArray *empty = nil; } } [internal->lock unlock]; + [self release]; } @end