diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index b550d4b36ac..13f92b1d777 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -408,6 +408,11 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent) break; } case NS_XUL_CLOSE: { + // Calling ExecuteCloseHandler may actually close the window + // (it probably shouldn't, but you never know what the users JS + // code will do). Therefore we add a death-grip to the window + // for the duration of the close handler. + nsCOMPtr kungFuDeathGrip(eventWindow); if (!eventWindow->ExecuteCloseHandler()) eventWindow->Close(); break;