Skip to content

Commit a32c9dc

Browse files
committed
NSException: Avoid re-throwing exception from within NS_HANDLER
1 parent 78a0098 commit a32c9dc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Source/NSOperation.m

+13-3
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ - (void) start
421421
ENTER_POOL
422422

423423
double prio = [NSThread threadPriority];
424+
NSException* caughtException = nil;
424425

425426
AUTORELEASE(RETAIN(self)); // Make sure we exist while running.
426427
[internal->lock lock];
@@ -453,12 +454,16 @@ - (void) start
453454
}
454455
NS_HANDLER
455456
{
456-
[internal->lock unlock];
457-
[localException raise];
457+
caughtException = localException;
458458
}
459459
NS_ENDHANDLER
460460
[internal->lock unlock];
461461

462+
if (caughtException != nil)
463+
{
464+
[caughtException raise];
465+
}
466+
462467
NS_DURING
463468
{
464469
if (NO == [self isCancelled])
@@ -470,10 +475,15 @@ - (void) start
470475
NS_HANDLER
471476
{
472477
[NSThread setThreadPriority: prio];
473-
[localException raise];
478+
caughtException = localException;
474479
}
475480
NS_ENDHANDLER;
476481

482+
if (caughtException != nil)
483+
{
484+
[caughtException raise];
485+
}
486+
477487
[self _finish];
478488
LEAVE_POOL
479489
}

0 commit comments

Comments
 (0)