ahh, i see (had a splash screen, added a alertBox to the Jucer to see whats going on, and so we have the same behaviour...)
But if we you use the AsyncUpdater-Method, we have also complete different behaviour on Windows (which uses the Initialise commandLine), also we have to care, because anotherInstanceStarted() on Mac is called before the async initialisation.
something like this:
- Code: Select all
void initialise (const String& commandLine)
{
initialiseCommandLine=commandLine;
triggerAsyncUpdate();
}
void handleAsyncUpdate()
{
SplashScreen* splash = new MainSplash();
splash->show(ApplicationName,470,200,1000,true,false);
// just create the main window...
mainWindow = new MyWindow();
// do init stuff etc...
String fileNameCommandLine=extractFileNameFromCommandLine(initialiseCommandLine);
if (fileNameToOpenAfterInit.isNotEmpty())
{
mainWindow->openFile(fileNameToOpenAfterInit);
fileNameToOpenAfterInit="";
} else
{
if (fileNameCommandLine.isNotEmpty())
{
mainWindow->openFile(fileNameCommandLine);
};
}
};
void anotherInstanceStarted (const String& commandLine)
{
String fileName=extractFileNameFromCommandLine(commandLine);
if (fileName.isNotEmpty())
{
if (mainWindow!=0)
{
mainWindow->openFile(fileName);
} else
{
// Application not intialised yet!
fileNameToOpenAfterInit=fileName;
}
}
}
bool moreThanOneInstanceAllowed()
{
return false;
}
private:
String fileNameToOpenAfterInit;
String initialiseCommandLine;
};