Skip to content

Commit 6fea8bd

Browse files
committed
NSProgress: Add cancellation logic
1 parent 591a9d1 commit 6fea8bd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Source/NSProgress.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#import "Foundation/NSThread.h"
7272
#import "Foundation/NSKeyValueObserving.h"
7373
#import "GNUstepBase/NSObject+GNUstepBase.h"
74+
#import "GSFastEnumeration.h"
7475

7576
#define GSInternal NSProgressInternal
7677
#include "GSInternal.h"
@@ -453,10 +454,20 @@ - (BOOL) cancelled
453454

454455
- (void) cancel
455456
{
457+
GS_MUTEX_LOCK(_lock);
456458
[self willChangeValueForKey: @"cancelled"];
457459
CALL_BLOCK_NO_ARGS(internal->_cancellationHandler);
458460
internal->_cancelled = YES;
459461
[self didChangeValueForKey: @"cancelled"];
462+
463+
// Cancel all child progresses
464+
FOR_IN(NSProgress*, child, _children)
465+
{
466+
[child cancel];
467+
}
468+
END_FOR_IN(children)
469+
470+
GS_MUTEX_UNLOCK(_lock);
460471
}
461472

462473
- (void) setCancellationHandler: (GSProgressCancellationHandler) handler

0 commit comments

Comments
 (0)