mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
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:
parent
a6560e18bb
commit
db0525f091
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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,20 +157,21 @@ void nsMacCommandLine::SetupCommandLine(int& argc, char**& argv)
|
||||
// Process Apple Events and put them into the arguments.
|
||||
Initialize(argc, argv);
|
||||
|
||||
Boolean isForeground = PR_FALSE;
|
||||
ProcessSerialNumber psnSelf, psnFront;
|
||||
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.
|
||||
if (::GetCurrentProcess(&psnSelf) == noErr &&
|
||||
::GetFrontProcess(&psnFront) == noErr &&
|
||||
::SameProcess(&psnSelf, &psnFront, &isForeground) == noErr &&
|
||||
isForeground) {
|
||||
// The process is currently in the foreground. The relaunched
|
||||
// process should come to the front, too.
|
||||
AddToCommandLine("-foreground");
|
||||
// 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.
|
||||
if (::GetCurrentProcess(&psnSelf) == noErr &&
|
||||
::GetFrontProcess(&psnFront) == noErr &&
|
||||
::SameProcess(&psnSelf, &psnFront, &isForeground) == noErr &&
|
||||
isForeground) {
|
||||
// The process is currently in the foreground. The relaunched
|
||||
// process should come to the front, too.
|
||||
AddToCommandLine("-foreground");
|
||||
}
|
||||
}
|
||||
|
||||
argc = mArgsUsed;
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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_
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user