mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Fixing #228470; SUUnarchiver now makes its delegate calls on the main thread instead of unsafely performing them on the alternate thread.
This commit is contained in:
1 parent
ff5001fe41
commit
7c709cb9fe
2 files changed
+22
-11
No files matched your search
@@ -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];
|
||||
|
||||
+21
-10
@@ -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
|
||||
Reference in new issue
Block a user