diff --git a/mozilla/toolkit/xre/nsAppRunner.cpp b/mozilla/toolkit/xre/nsAppRunner.cpp index 4124941c8a7..8a33cda8a45 100644 --- a/mozilla/toolkit/xre/nsAppRunner.cpp +++ b/mozilla/toolkit/xre/nsAppRunner.cpp @@ -949,11 +949,21 @@ ScopedXPCOMStartup::SetWindowCreator(nsINativeAppSupport* native) return wwatch->SetWindowCreator(creator); } +/** + * A helper class which calls NS_LogTerm/NS_LogTerm in it's scope. + */ +class ScopedLogging +{ +public: + ScopedLogging() { NS_LogInit(); } + ~ScopedLogging() { NS_LogTerm(); } +}; + static void DumpArbitraryHelp() { nsresult rv; - NS_LogInit(); + ScopedLogging log; { nsXREDirProvider dirProvider; @@ -973,8 +983,6 @@ static void DumpArbitraryHelp() if (NS_SUCCEEDED(rv)) printf("%s", text.get()); } - - NS_LogTerm(); } // English text needs to go into a dtd file. @@ -2303,6 +2311,8 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) } } + ScopedLogging log; + if (!appData.xreDirectory) { nsCOMPtr lf; rv = XRE_GetBinaryPath(gArgv[0], getter_AddRefs(lf)); @@ -2390,8 +2400,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) gArgc = argc = NS_TraceMallocStartupArgs(gArgc, gArgv); #endif - NS_LogInit(); - { nsXREDirProvider dirProvider; rv = dirProvider.Initialize(gAppData->directory, gAppData->xreDirectory); @@ -2928,7 +2936,5 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) } } - NS_LogTerm(); - return NS_FAILED(rv) ? 1 : 0; }