need to be able to Quit viewer via AppleEvent. r=sfraser

This commit is contained in:
beard%netscape.com 1999-11-02 01:49:52 +00:00
Родитель cca325f64a
Коммит 2e05fff9a0
1 изменённых файлов: 24 добавлений и 0 удалений

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

@ -364,6 +364,19 @@ nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID)
return status;
}
/**
* Quit AppleEvent handler.
*/
static pascal OSErr handleQuitApplication(const AppleEvent*, AppleEvent*, long)
{
if (gTheApp != nsnull) {
gTheApp->Exit();
} else {
ExitToShell();
}
return noErr;
}
#pragma mark -
//----------------------------------------------------------------------
int main(int argc, char **argv)
@ -371,6 +384,11 @@ int main(int argc, char **argv)
// Set up the toolbox and (if DEBUG) the console
InitializeMacToolbox();
// Install an a Quit AppleEvent handler.
OSErr err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
NewAEEventHandlerProc(handleQuitApplication), 0, false);
NS_ASSERTION((err==noErr), "AEInstallEventHandler failed");
// Start up XPCOM?
nsresult rv = NS_InitXPCOM(nsnull, nsnull, nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
@ -387,6 +405,12 @@ int main(int argc, char **argv)
NS_RELEASE(gTheApp);
}
#ifdef DETECT_WEBSHELL_LEAKS
if ( unsigned long count = NS_TotalWebShellsInExistence() ) {
printf("XXX WARNING: Number of webshells being leaked: %d \n", count);
}
#endif
// Shutdown XPCOM?
rv = NS_ShutdownXPCOM(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");