diff --git a/mozilla/lib/mac/NSStdLib/SIOUXExport.exp b/mozilla/lib/mac/NSStdLib/SIOUXExport.exp index 44c592e5eff..5ebd323da8e 100644 --- a/mozilla/lib/mac/NSStdLib/SIOUXExport.exp +++ b/mozilla/lib/mac/NSStdLib/SIOUXExport.exp @@ -1,3 +1,3 @@ InitializeSIOUX SIOUXHandleOneEvent - +InitializeMacToolbox diff --git a/mozilla/lib/mac/NSStdLib/include/macstdlibextras.h b/mozilla/lib/mac/NSStdLib/include/macstdlibextras.h index 12478159f47..392daabcd92 100644 --- a/mozilla/lib/mac/NSStdLib/include/macstdlibextras.h +++ b/mozilla/lib/mac/NSStdLib/include/macstdlibextras.h @@ -31,6 +31,8 @@ extern int strcasecmp(const char*, const char*); extern int strncasecmp(const char*, const char*, int length); +extern void InitializeMacToolbox(void); // also calls InitializeSIOUX(false) if DEBUG. + #if DEBUG extern void InitializeSIOUX(unsigned char isStandAlone); #endif /* DEBUG */ diff --git a/mozilla/lib/mac/NSStdLib/src/macstdlibextras.c b/mozilla/lib/mac/NSStdLib/src/macstdlibextras.c index e5eea860e03..5b0890f1f3e 100644 --- a/mozilla/lib/mac/NSStdLib/src/macstdlibextras.c +++ b/mozilla/lib/mac/NSStdLib/src/macstdlibextras.c @@ -15,15 +15,17 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ + +#include "macstdlibextras.h" + + #include #include #include #include #include - -#include "macstdlibextras.h" - +#include int strcmpcore(const char*, const char*, int, int); @@ -129,6 +131,28 @@ char *strdup(const char *source) return newAllocation; } +#pragma mark - + + +void InitializeMacToolbox(void) +{ + // once only, macintosh specific initialization + static Boolean alreadyInitialized = false; + if (!alreadyInitialized) + { + alreadyInitialized = true; + InitGraf(&qd.thePort); + InitFonts(); + InitWindows(); + InitMenus(); + TEInit(); + InitDialogs(0); + InitCursor(); +#if DEBUG + InitializeSIOUX(false); +#endif + } +} #pragma mark - diff --git a/mozilla/webshell/tests/viewer/nsMacMain.cpp b/mozilla/webshell/tests/viewer/nsMacMain.cpp index 72d02fe4ead..e087aabaa7e 100644 --- a/mozilla/webshell/tests/viewer/nsMacMain.cpp +++ b/mozilla/webshell/tests/viewer/nsMacMain.cpp @@ -292,10 +292,8 @@ nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID) int main(int argc, char **argv) { -#if DEBUG - // Set up the console - InitializeSIOUX(false); -#endif // DEBUG + // Set up the toolbox and (if DEBUG) the console + InitializeMacToolbox(); // Hack to get il_ss set so it doesn't fail in xpcompat.c nsIImageManager *manager; diff --git a/mozilla/widget/src/mac/nsAppShell.cpp b/mozilla/widget/src/mac/nsAppShell.cpp index f3ff8ca42f4..b450038ee5c 100644 --- a/mozilla/widget/src/mac/nsAppShell.cpp +++ b/mozilla/widget/src/mac/nsAppShell.cpp @@ -41,6 +41,8 @@ #include +#include "macstdlibextras.h" + PRBool nsAppShell::mInitializedToolbox = PR_FALSE; @@ -121,19 +123,13 @@ NS_IMETHODIMP nsAppShell::Exit() //------------------------------------------------------------------------- nsAppShell::nsAppShell() { - // once only, macintosh specific initialization - if (mInitializedToolbox == PR_FALSE) - { - mInitializedToolbox = PR_TRUE; - InitGraf(&qd.thePort); - InitFonts(); - InitWindows(); - InitMenus(); - TEInit(); - InitDialogs(0); - InitCursor(); - } - + // The toolbox initialization code has moved to NSStdLib (InitializeToolbox) + + if (!mInitializedToolbox) + { + InitializeMacToolbox(); + mInitializedToolbox == PR_TRUE; + } mRefCnt = 0; mExitCalled = PR_FALSE; } diff --git a/mozilla/xpfe/bootstrap/nsAppRunner.cpp b/mozilla/xpfe/bootstrap/nsAppRunner.cpp index cd37d8aa5b8..f24a12729b7 100644 --- a/mozilla/xpfe/bootstrap/nsAppRunner.cpp +++ b/mozilla/xpfe/bootstrap/nsAppRunner.cpp @@ -26,6 +26,13 @@ #include "nsIAppShellService.h" #include "nsAppShellCIDs.h" +#if defined(XP_MAC) +#include "macstdlibextras.h" + // Set up the toolbox and (if DEBUG) the console. Do this in a static initializer, + // to make it as unlikely as possible that somebody calls printf() before we get initialized. +static struct MacInitializer { MacInitializer() { InitializeMacToolbox(); } } gInitializer; +#endif // XP_MAC + /* Define Class IDs */ static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID); static NS_DEFINE_IID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID); @@ -50,7 +57,7 @@ static int TranslateReturnValue(nsresult aResult) extern "C" void NS_SetupRegistry_1(); -void +static void PrintUsage(void) { fprintf(stderr, "Usage: apprunner \n"); @@ -181,14 +188,14 @@ int main(int argc, char* argv[]) controllerCID = "43147b80-8a39-11d2-9938-0080c7cb1081"; appShell->CreateTopLevelWindow(url, controllerCID, newWindow); NS_RELEASE(url); + + /* + * Start up the main event loop... + */ + rv = appShell->Run(); /* - * Start up the main event loop... - */ - rv = appShell->Run(); - - /* - * Shutdown the Shell instance... This is done even if the Run(...) + * Shut down the Shell instance... This is done even if the Run(...) * method returned an error. */ (void) appShell->Shutdown();