added autorelease pool around each operation to catch any autoreleased

objects produced by the operation being executed. This should prevent
objects living until the end of the thread.
This commit is contained in:
Richard Frith-Macdonald 2020-09-30 09:56:24 +01:00
parent 6ae48bd3d3
commit 98dfa140ec

View file

@ -538,7 +538,7 @@ static NSArray *empty = nil;
@end
@implementation NSBlockOperation
+ (instancetype) blockOperationWithBlock: (GSBlockOperationBlock)block
@ -989,6 +989,11 @@ static NSOperationQueue *mainQueue = nil;
forKey: threadKey];
for (;;)
{
/* We use a pool for each operation in case releasing the operation
* causes it to be deallocated, and the deallocation of the operation
* autoreleases something which needs to be cleaned up.
*/
ENTER_POOL
NSOperation *op;
NSDate *when;
BOOL found;
@ -1040,6 +1045,7 @@ static NSOperationQueue *mainQueue = nil;
[op _finish];
RELEASE(op);
}
LEAVE_POOL
}
[[[NSThread currentThread] threadDictionary] removeObjectForKey: threadKey];