Hi,
I'm trying implement a restart procedure that would happen after an update of our application.
I was following the discussion here: http://www.juce.com/forum/topic/application-restart
modify your code so that you allow a second instance IF there is a specific command line option, and the second instance tells the previous instance to exit.
seems like a neat solution.
However I'm having an issue where anotherInstanceStarted() isn't being called as expected.
* I'm running JUCE v3.0.1
* Created a new basic window app from the Introjucer
* Set moreThanOneInstanceAllowed() to return true
* Added a logging statement to anotherInstanceStarted() in Main.cpp:
void anotherInstanceStarted (const String& commandLine)
{
DBG("Another Instance Started: " << commandLine);
}
* Run the application from Xcode (Debug configuration)
* From the project directory run another instance of the app in the command line:
$ ./Builds/MacOSX/build/Debug/Restart_Test_GUI_2.app/Contents/MacOS/Restart_Test_GUI_2
From the documentation I would expect anotherInstanceStarted() to be called in the first instance I opened. However I don't get any callbacks in either app. Changing moreThanOneInstanceAllowed() to return false quits the second instance on launch as expected but it still doesn't give me a callback.
----------------
From digging around in JuceApplicationBase it looks like if moreThanOneInstanceAllowed() is true then the sendCommandLineToPreexistingInstance() method is never executed, and therefore never instantiates the MultipleInstanceHandler and registers it as a ActionBroadcastListener for the callback.
if ((! moreThanOneInstanceAllowed()) && sendCommandLineToPreexistingInstance())
{
DBG ("Another instance is running - quitting...");
return false;
}
-----
Am I missing something fundamental to get this to work? Or is this a potential bug in JUCE?
Is there an easier solution for an update procedure? My general aim was as follows:
* Replace the old binary with the new one
* Run a script to launch a new instance of the application (with some command line params)
* Upon launch the initial instance detects it's an update and shuts itself down
Thanks in advance,
Joe