rv = InitializeWindowCreator(); NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize window creator"); if (NS_FAILED(rv)) return rv;
static nsresult main1(int argc, char* argv[], nsISupports *nativeApp ){  nsresult rv;#ifdef DEBUG_warren//  _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF);#endif#ifndef XP_MAC  // Unbuffer debug output (necessary for automated QA performance scripts).  setbuf( stdout, 0 );#endif#if defined(FREEBSD)  // Disable all SIGFPE's on FreeBSD, as it has non-IEEE-conformant fp  // trap behavior that trips up on floating-point tests performed by  // the JS engine.  See bugzilla bug 9967 details.  fpsetmask(0);#endif  nsCOMPtr<nsIEventQueueService> eventQService(do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv));  if (NS_SUCCEEDED(rv)) {    // XXX: What if this fails?    rv = eventQService->CreateThreadEventQueue();  }  // Setup an autoreg obserer, so that we can update a progress  // string in the splash screen  nsCOMPtr<nsIObserverService> obsService(do_GetService(NS_OBSERVERSERVICE_CONTRACTID));  if (obsService)  {    nsCOMPtr<nsIObserver> splashScreenObserver(do_QueryInterface(nativeApp));    if (splashScreenObserver)    {      obsService->AddObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get());    }  }  //----------------------------------------------------------------  // XPInstall needs to clean up after any updates that couldn't  // be completed because components were in use. This must be done  // **BEFORE** any other libraries are loaded!  //  // Will also check to see if AutoReg is required due to version  // change or installation of new components. If for some reason  // XPInstall can't be loaded we assume Autoreg is required.  //  // (scoped in a block to force release of COMPtr)  //----------------------------------------------------------------  PRBool needAutoreg = PR_TRUE;  {    nsCOMPtr<nsISoftwareUpdate> su(do_GetService(NS_IXPINSTALLCOMPONENT_CONTRACTID, &rv));    if (NS_SUCCEEDED(rv))      su->StartupTasks(&needAutoreg);  }#if XP_MAC  stTSMCloser  tsmCloser;  rv = InitializeMacCommandLine( argc, argv);  NS_ASSERTION(NS_SUCCEEDED(rv), "Initializing AppleEvents failed");#endif  // XXX: This call will be replaced by a registry initialization...  NS_SetupRegistry_1( needAutoreg );  // remove the nativeApp as an XPCOM autoreg observer  if (obsService)  {    nsCOMPtr<nsIObserver> splashScreenObserver(do_QueryInterface(nativeApp));    if (splashScreenObserver)    {      obsService->RemoveObserver(splashScreenObserver, NS_ConvertASCIItoUCS2(NS_XPCOM_AUTOREGISTRATION_OBSERVER_ID).get());    }  }  // Start up the core services:    // Initialize the cmd line service  nsCOMPtr<nsICmdLineService> cmdLineArgs(do_GetService(kCmdLineServiceCID, &rv));  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get command line service");  if (NS_FAILED(rv)) {    NS_ASSERTION(PR_FALSE, "Could not obtain CmdLine processing service\n");    return rv;  }  rv = cmdLineArgs->Initialize(argc, argv);  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize command line args");  if (rv == NS_ERROR_INVALID_ARG) {    PrintUsage();    return rv;  }  nsCOMPtr<nsIAppShellService> appShell(do_GetService(kAppShellServiceCID, &rv));  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get the appshell service");  /* if we couldn't get the nsIAppShellService service, then we should hide the     splash screen and return */  if (NS_FAILED(rv)) {    // See if platform supports nsINativeAppSupport.    nsCOMPtr<nsINativeAppSupport> nativeAppSupport(do_QueryInterface(nativeApp));    if (nativeAppSupport) {      // Use that interface to remove splash screen.      nativeAppSupport->HideSplashScreen();    } else {      // See if platform supports nsISplashScreen, instead.      nsCOMPtr<nsISplashScreen> splashScreen(do_QueryInterface(nativeApp));      if (splashScreen) {        splashScreen->Hide();      }    }    // Release argument object.    NS_IF_RELEASE(nativeApp);    return rv;  }  // Create the Application Shell instance...  rv = appShell->Initialize(cmdLineArgs, nativeApp);  // We are done with the native app (or splash screen) object here;  // the app shell owns it now.  NS_IF_RELEASE(nativeApp);  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to initialize appshell");  if (NS_FAILED(rv)) return rv;  // Initialize Profile Service here.  rv = InitializeProfileService(cmdLineArgs);  if (NS_FAILED(rv)) return rv;  // Enumerate AppShellComponenets  appShell->EnumerateAndInitializeComponents();  // rjc: now must explicitly call appshell's CreateHiddenWindow() function AFTER profile manager.  //      if the profile manager ever switches to using nsIDOMWindowInternal stuff, this might have to change  appShell->CreateHiddenWindow();	// This will go away once Components are handling there own commandlines	// if we have no command line arguments, we need to heed the	// "general.startup.*" prefs	// if we had no command line arguments, argc == 1.#ifdef XP_MAC	// if we do no command line args on the mac, it says argc is 0, and not 1	rv = DoCommandLines( cmdLineArgs, ((argc == 1) || (argc == 0)) );#else	rv = DoCommandLines( cmdLineArgs, (argc == 1) );#endif /* XP_MAC */    NS_ASSERTION(NS_SUCCEEDED(rv), "failed to process command line");	if ( NS_FAILED(rv) )    return rv;  // Make sure there exists at least 1 window.  rv = Ensure1Window( cmdLineArgs );  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to Ensure1Window");  if (NS_FAILED(rv)) return rv;  // Startup wallet service so it registers for notifications  nsCOMPtr<nsIWalletService> walletService(do_GetService(NS_WALLETSERVICE_CONTRACTID, &rv));                    InitCachePrefs();	  // Start main event loop  rv = appShell->Run();  NS_ASSERTION(NS_SUCCEEDED(rv), "failed to run appshell");  /*   * Shut down the Shell instance...  This is done even if the Run(...)   * method returned an error.   */  (void) appShell->Shutdown();  return rv;}