Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparkle not silently updating on exit #892

Closed
tfar opened this issue Sep 21, 2016 · 4 comments
Closed

Sparkle not silently updating on exit #892

tfar opened this issue Sep 21, 2016 · 4 comments

Comments

@tfar
Copy link

tfar commented Sep 21, 2016

I develop a C++/Qt application and want to use Sparkle for silent automatic updates on macOS.

The relevant Sparkle setup code looks like:

    d->updater = [SUUpdater sharedUpdater];
    [d->updater retain];

    d->delegate = boost::intrusive_ptr<SparkleAutoUpdaterDelegate>([[SparkleAutoUpdaterDelegate alloc] init], false);
    [d->updater setDelegate: d->delegate.get()];

    [d->updater setAutomaticallyChecksForUpdates: true];
    [d->updater setUpdateCheckInterval: 86400];
    [d->updater setAutomaticallyDownloadsUpdates: true];

    NSURL* nsurl = [NSURL URLWithString: std2NSString(url)];
    [d->updater setFeedURL: nsurl];
    [d->updater checkForUpdatesInBackground]; // Just for testing.

The delegate only outputs debug info:

-[SparkleAutoUpdaterDelegate updater:didFinishLoadingAppcast:]:
-[SparkleAutoUpdaterDelegate versionComparatorForUpdater:]:
-[SparkleAutoUpdaterDelegate updater:didFindValidUpdate:]:

.. logging output of Sparkle extracting the downloaded dmg, etc.

-[SparkleAutoUpdaterDelegate updater:willInstallUpdateOnQuit:immediateInstallationInvocation:]:

However, the downloaded and extracted new app bundle is never installed on exit. If I go the non-silent, non-automatic route and in the dialog click the install button, it's installed.

Isn't Sparkle to automatically run the install routines on exit? Browsing the code on GItHub I see a NSInvocation being prepared for this case, https://github.com/sparkle-project/Sparkle/blob/master/Sparkle/SUAutomaticUpdateDriver.m#L81, however I don't see where this is executed on exit. Same goes for the willUpdateOnTermination property in the same file. Shouldn't there be a hook in Sparkle that's called before quite and that installs the update?

@tfar tfar changed the title Sparkle not updating on exit Sparkle not silently updating on exit Sep 21, 2016
@zorgiepoo
Copy link
Member

The cocoa app termination event probably isn't being fired by Qt. Currently a defect that Sparkle even relies on this event, but see #839 for possible workarounds.

@tfar
Copy link
Author

tfar commented Sep 21, 2016

@zorgiepoo Thanks for the pointer. Will try that workaround later today and report back.

@tfar
Copy link
Author

tfar commented Sep 22, 2016

Indeed. Adding [[NSNotificationCenter defaultCenter] postNotificationName:@"NSApplicationWillTerminateNotification" object:nil]; before my program exists will kick off the update routine. Maybe this could be added to the documentation.

@zorgiepoo
Copy link
Member

Note Sparkle 2 doesn't need posting of NSApplicationWillTerminateNotification anymore. Please don't do this with Sparkle 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants