Fix for focus crash bugs 107844, 104297, and 109645. Make sure the window doesn't get deleted out from under us. r=saari, sr=blizzard.

This commit is contained in:
bryner%netscape.com 2002-01-16 03:36:50 +00:00
parent 68c2123b34
commit 5491e0a08e

View File

@ -575,6 +575,11 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
nsCOMPtr<nsIDOMWindowInternal> focusedWindow;
focusController->GetFocusedWindow(getter_AddRefs(focusedWindow));
if (focusedWindow) {
// It's possible for focusing the window to cause it to close.
// To avoid holding a pointer to deleted memory, keep a reference
// on eventWindow. -bryner
nsCOMPtr<nsIWebShellWindow> kungFuDeathGrip(eventWindow);
focusController->SetSuppressFocus(PR_TRUE, "Activation Suppression");
domWindow->Focus(); // This sets focus, but we'll ignore it.
// A subsequent activate will cause us to stop suppressing.