Added a new InitializeMacToolbox() to NSStdLib (declared in macstdlibextras.h) and exported it. This makes all the Mac Toolbox Init calls, and also (if DEBUG) initializes SIOUX without menus. Safe to call this multiple times (it has a static boolean). Removed toolbox initialization from constructor of nsAppShell, and called InitializeMacToolbox() instead. Called InitializeMacToolbox from main in viewer app, and also from a static initializer in nsAppRunner.cpp.

This commit is contained in:
mcmullen%netscape.com 1999-01-27 02:11:56 +00:00
Родитель 2549f2d4dd
Коммит a58105db04
6 изменённых файлов: 55 добавлений и 28 удалений

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

@ -1,3 +1,3 @@
InitializeSIOUX
SIOUXHandleOneEvent
InitializeMacToolbox

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

@ -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 */

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

@ -15,15 +15,17 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "macstdlibextras.h"
#include <Types.h>
#include <Memory.h>
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include "macstdlibextras.h"
#include <Quickdraw.h>
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 -

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

@ -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;

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

@ -41,6 +41,8 @@
#include <stdlib.h>
#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;
}

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

@ -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 <url>\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();