nsCOMPtr<nsIBaseWindow> hiddenWin(do_QueryInterface(mHiddenWindow)); if (!hiddenWin) Quit();
if (mHiddenWindow) {  nsIWidget* widget = NULL; mHiddenWindow->GetWidget( widget ); if( widget ) { widget->SetFocus();  widget->Release(); } } else {   Quit(); }
nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow){	if (mDeleteCalled) {		// return an error code in order to:		// - avoid doing anything with other member variables while we are in the destructor		// - notify the caller not to release the AppShellService after unregistering the window		//   (we don't want to be deleted twice consecutively to mHiddenWindow->Close() in our destructor)		return NS_ERROR_FAILURE;	}    if(mWindowMediator)     mWindowMediator->UnregisterWindow(aWindow);	  nsresult rv;  mWindowList->RemoveElement(aWindow);  PRUint32 cnt;  rv = mWindowList->Count(&cnt);  if (NS_FAILED(rv)) return rv;  if (0 == cnt)  {    if (!mQuitOnLastWindowClosing)      return NS_OK;        #if XP_MAC	 // if no hidden window is available (perhaps due to initial	 // Profile Manager window being cancelled), then just quit. We don't have	 // to worry about focussing the hidden window, because it will get activated	 // by the OS since it is visible (but waaaay offscreen).   nsCOMPtr<nsIBaseWindow> hiddenWin(do_QueryInterface(mHiddenWindow));	 if (!hiddenWin)		 Quit();  #else    // Check to see if we should quit in this case.    PRBool serverMode = PR_FALSE;    if (mNativeAppSupport)        mNativeAppSupport->GetIsServerMode(&serverMode);    if (serverMode)        return NS_OK;    Quit();  #endif   }  return rv;}