Because of the way Sparkle forces SUUpdaters to be per-bundle singletons, it was possible for an SUUpdater to be dealloced before registerAsObserver was called, which in turn made an exception get thrown on unregisterAsObserver.

This commit is contained in:
Andy Matuschak committed 2010-09-13 10:28:18 -07:00
1 parent fba7231261
commit 561bbbe294
1 file changed
+5 -1
+5 -1
View File
@@ -56,6 +56,11 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
{
self = [super init];
if (bundle == nil) bundle = [NSBundle mainBundle];
// Register as observer straight away to avoid exceptions on -dealloc when -unregisterAsObserver is called:
if (self)
[self registerAsObserver];
id updater = [sharedUpdaters objectForKey:[NSValue valueWithNonretainedObject:bundle]];
if (updater)
{
@@ -68,7 +73,6 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault
sharedUpdaters = [[NSMutableDictionary alloc] init];
[sharedUpdaters setObject:self forKey:[NSValue valueWithNonretainedObject:bundle]];
host = [[SUHost alloc] initWithBundle:bundle];
[self registerAsObserver];
// Saving-the-developer-from-a-stupid-mistake-check:
if (![[[self feedURL] scheme] isEqualToString:@"https"] && ![host publicDSAKey])