diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index 150a0e3a..a1d2f105 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -181,7 +181,7 @@ @catch (NSException *e) { // Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin. - [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [NSApp name]], NSLocalizedDescriptionKey, [e reason], NSLocalizedFailureReasonErrorKey, nil]]]; + [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [[NSBundle mainBundle] name]], NSLocalizedDescriptionKey, [e reason], NSLocalizedFailureReasonErrorKey, nil]]]; // We intentionally don't abandon the update here so that the host won't initiate another. } [NSApp terminate:self]; diff --git a/SUUnarchiver.m b/SUUnarchiver.m index 118205f1..409b86fc 100644 --- a/SUUnarchiver.m +++ b/SUUnarchiver.m @@ -41,8 +41,7 @@ fwrite(buf, 1, len, cmdFP); - if ([delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) - [delegate unarchiver:self extractedLength:len]; + [self performSelectorOnMainThread:@selector(notifyDelegateOfExtractedLength:) withObject:[NSNumber numberWithLong:len] waitUntilDone:NO]; } pclose(cmdFP); } @@ -140,15 +139,9 @@ result = NO; if (result) - { - if ([delegate respondsToSelector:@selector(unarchiverDidFinish:)]) - [delegate performSelector:@selector(unarchiverDidFinish:) withObject:self]; - } + [self performSelectorOnMainThread:@selector(notifyDelegateOfSuccess) withObject:nil waitUntilDone:NO]; else - { - if ([delegate respondsToSelector:@selector(unarchiverDidFail:)]) - [delegate performSelector:@selector(unarchiverDidFail:) withObject:self]; - } + [self performSelectorOnMainThread:@selector(notifyDelegateOfFailure) withObject:nil waitUntilDone:NO]; [pool release]; } @@ -179,4 +172,22 @@ [super dealloc]; } +- (void)notifyDelegateOfExtractedLength:(long)length +{ + if ([delegate respondsToSelector:@selector(unarchiver:extractedLength:)]) + [delegate unarchiver:self extractedLength:length]; +} + +- (void)notifyDelegateOfSuccess +{ + if ([delegate respondsToSelector:@selector(unarchiverDidFinish:)]) + [delegate performSelector:@selector(unarchiverDidFinish:) withObject:self]; +} + +- (void)notifyDelegateOfFailure +{ + if ([delegate respondsToSelector:@selector(unarchiverDidFail:)]) + [delegate performSelector:@selector(unarchiverDidFail:) withObject:self]; +} + @end