bug 369147, "Warning: unrecognized command line flag -foreground" on launch

r=josh
Don't add the '-foreground' flag to the list of command line arguments if we're not restarting,
since no-one outside of XRE_main knows how to handle it.
This commit is contained in:
Nickolay Ponomarev 2010-04-17 13:50:17 +04:00
parent a6560e18bb
commit db0525f091
4 changed files with 25 additions and 24 deletions

View File

@ -1714,7 +1714,7 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative,
PR_SetEnv("MOZ_LAUNCHED_CHILD=1");
#if defined(XP_MACOSX)
SetupMacCommandLine(gRestartArgc, gRestartArgv);
SetupMacCommandLine(gRestartArgc, gRestartArgv, PR_TRUE);
LaunchChildMac(gRestartArgc, gRestartArgv);
#else
nsCOMPtr<nsILocalFile> lf;
@ -1919,7 +1919,7 @@ ShowProfileManager(nsIToolkitProfileService* aProfileSvc,
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
#ifdef XP_MACOSX
SetupMacCommandLine(gRestartArgc, gRestartArgv);
SetupMacCommandLine(gRestartArgc, gRestartArgv, PR_TRUE);
#endif
#ifdef XP_WIN
@ -2009,7 +2009,7 @@ ImportProfiles(nsIToolkitProfileService* aPService,
xpcom.RegisterProfileService();
#ifdef XP_MACOSX
SetupMacCommandLine(gRestartArgc, gRestartArgv);
SetupMacCommandLine(gRestartArgc, gRestartArgv, PR_TRUE);
#endif
nsCOMPtr<nsIProfileMigrator> migrator
@ -3468,7 +3468,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
cmdLine = do_CreateInstance("@mozilla.org/toolkit/command-line;1");
NS_ENSURE_TRUE(cmdLine, 1);
SetupMacCommandLine(gArgc, gArgv);
SetupMacCommandLine(gArgc, gArgv, PR_FALSE);
rv = cmdLine->Init(gArgc, gArgv,
workingDir, nsICommandLine::STATE_INITIAL_LAUNCH);
@ -3557,7 +3557,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
#endif
#ifdef XP_MACOSX
SetupMacCommandLine(gRestartArgc, gRestartArgv);
SetupMacCommandLine(gRestartArgc, gRestartArgv, PR_TRUE);
#endif
}
}

View File

@ -143,7 +143,7 @@ nsresult nsMacCommandLine::Initialize(int& argc, char**& argv)
return NS_OK;
}
void nsMacCommandLine::SetupCommandLine(int& argc, char**& argv)
void nsMacCommandLine::SetupCommandLine(int& argc, char**& argv, PRBool forRestart)
{
// Initializes the command line from Apple Events and other sources,
// as appropriate for OS X.
@ -157,13 +157,13 @@ void nsMacCommandLine::SetupCommandLine(int& argc, char**& argv)
// Process Apple Events and put them into the arguments.
Initialize(argc, argv);
if (forRestart) {
Boolean isForeground = PR_FALSE;
ProcessSerialNumber psnSelf, psnFront;
// If the process will be relaunched, the child should be in the foreground
// if the parent is in the foreground. This will be communicated in a
// command-line argument to the child. Adding this argument is harmless
// if not relaunching.
// command-line argument to the child.
if (::GetCurrentProcess(&psnSelf) == noErr &&
::GetFrontProcess(&psnFront) == noErr &&
::SameProcess(&psnSelf, &psnFront, &isForeground) == noErr &&
@ -172,6 +172,7 @@ void nsMacCommandLine::SetupCommandLine(int& argc, char**& argv)
// process should come to the front, too.
AddToCommandLine("-foreground");
}
}
argc = mArgsUsed;
argv = mArgs;
@ -322,8 +323,8 @@ nsresult nsMacCommandLine::DispatchURLToNewBrowser(const char* url)
#pragma mark -
void SetupMacCommandLine(int& argc, char**& argv)
void SetupMacCommandLine(int& argc, char**& argv, PRBool forRestart)
{
nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
return cmdLine.SetupCommandLine(argc, argv);
return cmdLine.SetupCommandLine(argc, argv, forRestart);
}

View File

@ -59,7 +59,7 @@ public:
~nsMacCommandLine();
nsresult Initialize(int& argc, char**& argv);
void SetupCommandLine(int& argc, char**& argv);
void SetupCommandLine(int& argc, char**& argv, PRBool forRestart);
nsresult AddToCommandLine(const char* inArgText);
nsresult AddToCommandLine(const char* inOptionString, const CFURLRef file);
@ -92,6 +92,6 @@ private:
};
void SetupMacCommandLine(int& argc, char**& argv);
void SetupMacCommandLine(int& argc, char**& argv, PRBool forRestart);
#endif // nsCommandLineServiceMac_h_

View File

@ -542,7 +542,7 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsILocalFile *statusFile,
goto end;
#ifdef XP_MACOSX
SetupMacCommandLine(argc, argv);
SetupMacCommandLine(argc, argv, PR_TRUE);
#endif
PR_CreateProcessDetached(updaterPath.get(), argv, nsnull, attr);