mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Revert deferring startUpdateCycle in SUUpdater init
I decided it was less evil to allow SUUpdater to defer cycling and have a mutable delegate, than it was for SUUpdateController to have a nullable SUUpdater that could be instantiated an arbitrary time later I have also changed the delay from 0 to 1, on the safer side.
This commit is contained in:
1 parent
1da4ee961c
commit
8b0eae8ef4
4 files changed
+9
-20
No files matched your search
Vendored
+1
-1
@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle delegate:(_Nullable id <SUSparkleUserDriverDelegate>)delegate;
|
||||
|
||||
@property (nonatomic, readonly, weak, nullable) id <SUSparkleUserDriverDelegate> delegate;
|
||||
@property (nonatomic, weak, nullable) id <SUSparkleUserDriverDelegate> delegate;
|
||||
|
||||
@property (nonatomic, readonly, getter=isUpdateInProgress) BOOL updateInProgress;
|
||||
|
||||
|
||||
Vendored
+3
-1
@@ -72,7 +72,9 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateDriverDidFinish:) name:SUUpdateDriverFinishedNotification object:nil];
|
||||
|
||||
[self startUpdateCycle];
|
||||
// This runs the permission prompt if needed, but never before the app has finished launching because the runloop may not have ran before that
|
||||
// We will also take precaussions if a developer instantiates an updater themselves where the application may not be completely finished launching yet
|
||||
[self performSelector:@selector(startUpdateCycle) withObject:nil afterDelay:1];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
Vendored
+1
-6
@@ -31,18 +31,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/*!
|
||||
Initializes a new updater controller instance. Typically this class is instantiated in a nib, thus this
|
||||
method is not usually called directly by the developer.
|
||||
|
||||
Note that this defers instantiation of its SUUpdater to the next cycle in Cocoa's runloop.
|
||||
This is to prevent starting the updater cycle when the application may not be ready yet.
|
||||
*/
|
||||
- (instancetype)init;
|
||||
|
||||
/*!
|
||||
Accessible property for the updater. Some properties on the updater can be binded via KVO
|
||||
|
||||
The updater may be nil, which means its instantiation is deferred to the next runloop cycle.
|
||||
*/
|
||||
@property (nonatomic, readonly, nullable) SUUpdater *updater;
|
||||
@property (nonatomic, readonly) SUUpdater *updater;
|
||||
|
||||
/*!
|
||||
Explicitly checks for updates and displays a progress dialog while doing so.
|
||||
|
||||
Vendored
+4
-12
@@ -31,10 +31,9 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
if (self != nil) {
|
||||
[self registerAsObserver];
|
||||
|
||||
// We don't want the updater to start its updating cycle before the app has finished launching
|
||||
// If this is instantiated in a nib, the runloop may not be ready
|
||||
// Furthermore, this delay allows setting the updater and user driver delegates before the updater initializes
|
||||
[self performSelector:@selector(instantiateUpdater) withObject:nil afterDelay:0];
|
||||
NSBundle *hostBundle = [NSBundle mainBundle];
|
||||
id <SUUserDriver> driver = [[SUSparkleUserDriver alloc] initWithHostBundle:hostBundle delegate:nil];
|
||||
self.updater = [[SUUpdater alloc] initWithHostBundle:hostBundle userDriver:driver delegate:nil];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -44,13 +43,6 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
[self unregisterAsObserver];
|
||||
}
|
||||
|
||||
- (void)instantiateUpdater
|
||||
{
|
||||
NSBundle *hostBundle = [NSBundle mainBundle];
|
||||
id <SUUserDriver> driver = [[SUSparkleUserDriver alloc] initWithHostBundle:hostBundle delegate:nil];
|
||||
self.updater = [[SUUpdater alloc] initWithHostBundle:hostBundle userDriver:driver delegate:nil];
|
||||
}
|
||||
|
||||
- (IBAction)checkForUpdates:(id)__unused sender
|
||||
{
|
||||
[self.updater checkForUpdates];
|
||||
@@ -59,7 +51,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item
|
||||
{
|
||||
if ([item action] == @selector(checkForUpdates:)) {
|
||||
return (self.updater != nil && !self.updater.updateInProgress);
|
||||
return !self.updater.updateInProgress;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user