Doesn't Relaunch Mail After updating Mail Plugin

Asked by smorr

Download, unarchive and install all work for using Sparkle 1.5b4 in a Mail Plugin -- however, relaunch just doesn't happen.

For my own purposes, I've patched
SUBasicUpdateDriver.m

Line 251
 [NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:[hostBundle bundlePath], [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];

To
 [NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:[[NSBundle mainBundle] bundlePath], [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];

I don't know if there is a more official way of doing this.

Question information

Language:
English Edit question
Status:
Answered
For:
Sparkle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Andy Matuschak (andymatuschak) said :
#1

Hm. Tricky. Thing is, that's not *always* the right thing to do: in the case of a prefpane or a plugin like that updating, you want to launch the plugin (since the host app will then take the user precisely where he's supposed to go). In this case, though, we want to relaunch the host app, since for Mail, there's no sense in "bringing you to the right place."

It seems kind of silly to make a delegate method just for this. Any ideas?

Revision history for this message
smorr (smorr) said :
#2

Actually, a delegate method probably is the thing to do for best flexibility -- it really costs nothing and as it amounts to a informal protocol, most coders can safely ignore it:

Here is my updated code for SUBasicUpdateDriver.m
--- snip at line 250
 NSString * pathOfBundleToRelaunch = [hostBundle bundlePath];
 if ([delegate respondsToSelector:@selector(pathToRelaunch)]){
  pathOfBundleToRelaunch = [delegate pathToRelaunch];
 }
 [NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:pathOfBundleToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];

 [NSApp terminate:self];
---- snip

Then in my main plugin bundle (aka the delegate)
-(NSString*) pathToRelaunch{
 return [[NSBundle mainBundle] bundlePath];
}

I am using the framework but I have swizzled the relaunch relaunchHostApp to add in the message to the delegate and it works nicely.

Revision history for this message
Hofman (cmhofman) said :
#3

Here's another reason to add it. What if more than one bundles loaded for the same process want to use Sparkle (e.g. several plugins for a single app, or an app and a plugin,...)? Loading and linking Sparkle would probably fail. The best solution to this would probably be to launch a separate updater app containing Sparkle for secondary bundles. However this app must know which bundle to reload, and must be able to tell Sparkle.

Revision history for this message
smorr (smorr) said :
#4

One problem here is that SUUpdate is now a singleton -- And Andy (or someone) has put in big comment at the top:

// This will probably break the world if you try to write a Sparkle-enabled plugin for a Sparkle-enabled app.

As for working around this? Either make it not a singleton (which may be very problematic as there are probably numerous requests for the singleton littered throughout. or ???

Revision history for this message
Hofman (cmhofman) said :
#5

In 1.5b5 it won't be a strict singleton, without giving your last problem.

Revision history for this message
Andy Matuschak (andymatuschak) said :
#6

Alright, guys, you persuaded me. :) https://bugs.launchpad.net/bugs/253187

Can you help with this problem?

Provide an answer of your own, or ask smorr for more information if necessary.

To post a message you must log in.