зеркало из https://github.com/mozilla/pjs.git
Bug 386826 - "First run of XULRunner fails on Windows Vista, showing the Usage dialog instead" [p=roland.boon@tomtom.com (Roland Boon) r=bsmedberg a1.9=sayrer]
This commit is contained in:
Родитель
ac56755d97
Коммит
5b9eacaed9
|
@ -115,16 +115,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
// Allow firefox.exe to launch XULRunner apps via -app <application.ini>
|
||||
// Note that -app must be the *first* argument.
|
||||
char *appEnv = nsnull;
|
||||
const char *appDataFile = PR_GetEnv("XUL_APP_FILE");
|
||||
if (appDataFile && *appDataFile) {
|
||||
rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appini));
|
||||
if (NS_FAILED(rv)) {
|
||||
Output("Invalid path found: '%s'", appDataFile);
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
else if (argc > 1 && IsArg(argv[1], "app")) {
|
||||
if (argc > 1 && IsArg(argv[1], "app")) {
|
||||
if (argc == 2) {
|
||||
Output("Incorrect number of arguments passed to -app");
|
||||
return 255;
|
||||
|
@ -136,8 +127,6 @@ int main(int argc, char* argv[])
|
|||
return 255;
|
||||
}
|
||||
|
||||
appEnv = PR_smprintf("XUL_APP_FILE=%s", argv[2]);
|
||||
PR_SetEnv(appEnv);
|
||||
argv[2] = argv[0];
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
|
@ -150,10 +139,10 @@ int main(int argc, char* argv[])
|
|||
return 255;
|
||||
}
|
||||
|
||||
XRE_SetAppDataFile(appini);
|
||||
|
||||
int result = XRE_main(argc, argv, appData);
|
||||
XRE_FreeAppData(appData);
|
||||
if (appEnv)
|
||||
PR_smprintf_free(appEnv);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1558,7 +1558,7 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative,
|
|||
// if supported by the platform. Otherwise, use NSPR.
|
||||
|
||||
if (aBlankCommandLine) {
|
||||
gRestartArgc = 1;
|
||||
gRestartArgc = 1 + (gRestartArgc - gArgc);
|
||||
gRestartArgv[gRestartArgc] = nsnull;
|
||||
}
|
||||
|
||||
|
@ -2248,34 +2248,6 @@ static void RemoveComponentRegistries(nsIFile* aProfileDir, nsIFile* aLocalProfi
|
|||
file->Remove(PR_FALSE);
|
||||
}
|
||||
|
||||
// To support application initiated restart via nsIAppStartup.quit, we
|
||||
// need to save various environment variables, and then restore them
|
||||
// before re-launching the application.
|
||||
|
||||
static struct {
|
||||
const char *name;
|
||||
char *value;
|
||||
} gSavedVars[] = {
|
||||
{"XUL_APP_FILE", nsnull}
|
||||
};
|
||||
|
||||
static void SaveStateForAppInitiatedRestart()
|
||||
{
|
||||
for (size_t i = 0; i < NS_ARRAY_LENGTH(gSavedVars); ++i) {
|
||||
const char *s = PR_GetEnv(gSavedVars[i].name);
|
||||
if (s)
|
||||
gSavedVars[i].value = PR_smprintf("%s=%s", gSavedVars[i].name, s);
|
||||
}
|
||||
}
|
||||
|
||||
static void RestoreStateForAppInitiatedRestart()
|
||||
{
|
||||
for (size_t i = 0; i < NS_ARRAY_LENGTH(gSavedVars); ++i) {
|
||||
if (gSavedVars[i].value)
|
||||
PR_SetEnv(gSavedVars[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
// When we first initialize the crash reporter we don't have a profile,
|
||||
// so we set the minidump path to $TEMP. Once we have a profile,
|
||||
|
@ -2303,6 +2275,12 @@ static void MakeOrSetMinidumpPath(nsIFile* profD)
|
|||
#endif
|
||||
|
||||
const nsXREAppData* gAppData = nsnull;
|
||||
nsILocalFile* gAppDataFile = nsnull;
|
||||
|
||||
void XRE_SetAppDataFile(nsILocalFile* aAppDataFile)
|
||||
{
|
||||
SetStrongPtr(gAppDataFile, aAppDataFile);
|
||||
}
|
||||
|
||||
#if defined(XP_OS2)
|
||||
// because we use early returns, we use a stack-based helper to un-set the OS2 FP handler
|
||||
|
@ -2628,14 +2606,28 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
PR_SetEnv("MOZ_LAUNCHED_CHILD=");
|
||||
|
||||
gRestartArgc = gArgc;
|
||||
gRestartArgv = (char**) malloc(sizeof(char*) * (gArgc + 1));
|
||||
if (!gRestartArgv) return 1;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < gArgc; ++i) {
|
||||
gRestartArgv[i] = gArgv[i];
|
||||
if (gAppDataFile) {
|
||||
gRestartArgc += 2;
|
||||
}
|
||||
gRestartArgv[gArgc] = nsnull;
|
||||
gRestartArgv = (char**) malloc(sizeof(char*) * (gRestartArgc + 1));
|
||||
if (!gRestartArgv) return 1;
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
if (gAppDataFile) {
|
||||
// The first argument is the path to the executable. It needs to remain the first argument.
|
||||
if (gArgc) {
|
||||
gRestartArgv[j++] = gArgv[i++];
|
||||
}
|
||||
nsCAutoString iniPath;
|
||||
gAppDataFile->GetNativePath(iniPath);
|
||||
gRestartArgv[j++] = "--app";
|
||||
gRestartArgv[j++] = strdup(iniPath.get());
|
||||
}
|
||||
while (i < gArgc) {
|
||||
gRestartArgv[j++] = gArgv[i++];
|
||||
}
|
||||
gRestartArgv[gRestartArgc] = nsnull;
|
||||
|
||||
#if defined(XP_OS2)
|
||||
PRBool StartOS2App(int aArgc, char **aArgv);
|
||||
|
@ -3088,8 +3080,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
}
|
||||
|
||||
if (!upgraded && !needsRestart) {
|
||||
SaveStateForAppInitiatedRestart();
|
||||
|
||||
// clear out any environment variables which may have been set
|
||||
// during the relaunch process now that we know we won't be relaunching.
|
||||
PR_SetEnv("XRE_PROFILE_PATH=");
|
||||
|
@ -3098,7 +3088,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
PR_SetEnv("XRE_START_OFFLINE=");
|
||||
PR_SetEnv("XRE_IMPORT_PROFILES=");
|
||||
PR_SetEnv("NO_EM_RESTART=");
|
||||
PR_SetEnv("XUL_APP_FILE=");
|
||||
PR_SetEnv("XRE_BINARY_PATH=");
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
@ -3189,10 +3178,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
|
||||
// Restart the app after XPCOM has been shut down cleanly.
|
||||
if (needsRestart) {
|
||||
if (appInitiatedRestart) {
|
||||
RestoreStateForAppInitiatedRestart();
|
||||
}
|
||||
else {
|
||||
if (!appInitiatedRestart) {
|
||||
char* noEMRestart = PR_GetEnv("NO_EM_RESTART");
|
||||
if (noEMRestart && *noEMRestart) {
|
||||
PR_SetEnv("NO_EM_RESTART=1");
|
||||
|
|
|
@ -403,4 +403,13 @@ XRE_API(nsresult,
|
|||
XRE_API(void,
|
||||
XRE_FreeAppData, (nsXREAppData *aAppData))
|
||||
|
||||
/**
|
||||
* Stores the application.ini file to pass as an argument during a
|
||||
* possible restart. It should be called before calling XRE_main().
|
||||
*
|
||||
* @param aINIFile The application.ini file to store.
|
||||
*/
|
||||
XRE_API(void,
|
||||
XRE_SetAppDataFile, (nsILocalFile* aINIFile))
|
||||
|
||||
#endif // _nsXULAppAPI_h__
|
||||
|
|
|
@ -402,34 +402,26 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
const char *appDataFile = PR_GetEnv("XUL_APP_FILE");
|
||||
if (argc < 2) {
|
||||
Usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(appDataFile && *appDataFile)) {
|
||||
if (argc < 2) {
|
||||
if (IsArg(argv[1], "app")) {
|
||||
if (argc == 2) {
|
||||
Usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (IsArg(argv[1], "app")) {
|
||||
if (argc == 2) {
|
||||
Usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
argv[1] = argv[0];
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
|
||||
appDataFile = argv[1];
|
||||
argv[1] = argv[0];
|
||||
++argv;
|
||||
--argc;
|
||||
|
||||
static char kAppEnv[MAXPATHLEN];
|
||||
PR_snprintf(kAppEnv, MAXPATHLEN, "XUL_APP_FILE=%s", appDataFile);
|
||||
PR_SetEnv(kAppEnv);
|
||||
}
|
||||
|
||||
const char *appDataFile = argv[1];
|
||||
argv[1] = argv[0];
|
||||
++argv;
|
||||
--argc;
|
||||
|
||||
nsCOMPtr<nsILocalFile> appDataLF;
|
||||
nsresult rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appDataLF));
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -443,6 +435,8 @@ int main(int argc, char* argv[])
|
|||
return 2;
|
||||
}
|
||||
|
||||
XRE_SetAppDataFile(appDataLF);
|
||||
|
||||
return XRE_main(argc, argv, appData);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче