bug 526397: fix up command line init. no r=, minor

This commit is contained in:
Chris Jones 2009-11-03 23:12:18 -06:00
Родитель c916fbb575
Коммит 4bb319dfc5
4 изменённых файлов: 54 добавлений и 30 удалений

Просмотреть файл

@ -45,6 +45,8 @@ MODULE = ipdlunittest
PROGRAM = $(MODULE)$(BIN_SUFFIX)
ENABLE_CXX_EXCEPTIONS = 1
NSDISTMODE = copy
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
CPPSRCS = \

Просмотреть файл

@ -3035,30 +3035,8 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
MOZ_SPLASHSCREEN_UPDATE(20);
#if defined(MOZ_IPC) && !defined(OS_WIN)
// FIXME: this and its constituents leak
char** canonArgs = new char*[gArgc];
// get the canonical version of the binary's path
nsCOMPtr<nsILocalFile> binFile;
rv = XRE_GetBinaryPath(gArgv[0], getter_AddRefs(binFile));
NS_ENSURE_SUCCESS(rv, 2);
nsCAutoString canonBinPath;
rv = binFile->GetNativePath(canonBinPath);
NS_ENSURE_SUCCESS(rv, 2);
canonArgs[0] = strdup(canonBinPath.get());
for (int i = 1; i < gArgc; ++i) {
if (gArgv[i]) {
canonArgs[i] = strdup(gArgv[i]); // new[] zeros memory
}
}
NS_ASSERTION(!CommandLine::IsInitialized(), "Bad news!");
CommandLine::Init(gArgc, canonArgs);
#endif
rv = XRE_InitCommandLine(gArgc, gArgv);
NS_ENSURE_SUCCESS(rv, 1);
{
nsXREDirProvider dirProvider;

Просмотреть файл

@ -284,7 +284,11 @@ XRE_InitChildProcess(int aArgc,
"can't open handle to parent");
base::AtExitManager exitManager;
CommandLine::Init(aArgc, aArgv);
int rv = XRE_InitCommandLine(aArgc, aArgv);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
MessageLoopForIO mainMessageLoop;
{
@ -378,7 +382,9 @@ XRE_InitParentProcess(int aArgc,
NS_ENSURE_ARG_POINTER(aArgv);
NS_ENSURE_ARG_POINTER(aArgv[0]);
CommandLine::Init(aArgc, aArgv);
int rv = XRE_InitCommandLine(aArgc, aArgv);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
ScopedXREEmbed embed;
@ -430,6 +436,45 @@ XRE_RunIPDLTest(int aArgc, char** aArgv)
}
#endif // ifdef MOZ_IPDL_TESTS
nsresult
XRE_InitCommandLine(int aArgc, char* aArgv[])
{
nsresult rv = NS_OK;
#if defined(MOZ_IPC) && !defined(OS_WIN)
// these leak on error, but that's OK: we'll just exit()
char** canonArgs = new char*[aArgc];
// get the canonical version of the binary's path
nsCOMPtr<nsILocalFile> binFile;
rv = XRE_GetBinaryPath(aArgv[0], getter_AddRefs(binFile));
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
nsCAutoString canonBinPath;
rv = binFile->GetNativePath(canonBinPath);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
canonArgs[0] = strdup(canonBinPath.get());
for (int i = 1; i < aArgc; ++i) {
if (aArgv[i]) {
canonArgs[i] = strdup(aArgv[i]);
}
}
NS_ASSERTION(!CommandLine::IsInitialized(), "Bad news!");
CommandLine::Init(aArgc, canonArgs);
delete[] canonArgs;
#endif
return rv;
}
nsresult
XRE_RunAppShell()
{

Просмотреть файл

@ -465,10 +465,6 @@ XRE_API(nsresult,
MainFunction aMainFunction,
void* aMainFunctionExtraData))
XRE_API(int,
XRE_RunIPCTestHarness, (int aArgc,
char* aArgv[]))
XRE_API(int,
XRE_RunIPDLTest, (int aArgc,
char* aArgv[]))
@ -476,6 +472,9 @@ XRE_API(int,
XRE_API(nsresult,
XRE_RunAppShell, ())
XRE_API(nsresult,
XRE_InitCommandLine, (int aArgc, char* aArgv[]))
class MessageLoop;
XRE_API(void,