From 620f8e61690715e9dd1aa375c2ecfe11abff27f6 Mon Sep 17 00:00:00 2001 From: "saari%netscape.com" Date: Tue, 15 Feb 2000 00:28:43 +0000 Subject: [PATCH] Fix for crashes in EventStateManager that may people are seeing. Bug 27727. r=hyatt git-svn-id: svn://10.0.0.236/trunk@60753 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/events/src/nsEventStateManager.cpp | 9 +++++++-- mozilla/layout/events/src/nsEventStateManager.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 079847ebca9..0eba3d50cf3 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -552,8 +552,13 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, if (gLastFocusedContent) { nsCOMPtr doc; gLastFocusedContent->GetDocument(*getter_AddRefs(doc)); - doc->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - } + if(doc) + doc->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + else { + mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + NS_RELEASE(gLastFocusedContent); + } + } else mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); // Suppress the command dispatcher for the duration of the diff --git a/mozilla/layout/events/src/nsEventStateManager.cpp b/mozilla/layout/events/src/nsEventStateManager.cpp index 079847ebca9..0eba3d50cf3 100644 --- a/mozilla/layout/events/src/nsEventStateManager.cpp +++ b/mozilla/layout/events/src/nsEventStateManager.cpp @@ -552,8 +552,13 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext, if (gLastFocusedContent) { nsCOMPtr doc; gLastFocusedContent->GetDocument(*getter_AddRefs(doc)); - doc->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); - } + if(doc) + doc->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + else { + mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); + NS_RELEASE(gLastFocusedContent); + } + } else mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal)); // Suppress the command dispatcher for the duration of the