From e15232bf920a69b79350177b1d0a478a75fb48e2 Mon Sep 17 00:00:00 2001 From: "jkeiser%netscape.com" Date: Tue, 14 Jan 2003 05:54:38 +0000 Subject: [PATCH] Fix crash while document is going away (bug 168013), r=sicking@bugmail.cc, sr=sfraser@netscape.com --- .../html/content/src/nsHTMLInputElement.cpp | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index c5a86c62c72..3b568cbe14e 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -1180,15 +1180,19 @@ nsHTMLInputElement::Select() // If the DOM event was not canceled (e.g. by a JS event handler // returning false) if (status == nsEventStatus_eIgnore) { - nsCOMPtr esm; - if (NS_OK == presContext->GetEventStateManager(getter_AddRefs(esm))) { - PRInt32 currentState; - //XXX Fix for bug 135345 - ESM currently does not check to see if we have - //focus before attempting to set focus again and may cause infinite recursion. - //For now check if we have focus and do not set focus again if already focused. - esm->GetContentState(this, currentState); - if (!(currentState & NS_EVENT_STATE_FOCUS)) { - esm->SetContentState(this, NS_EVENT_STATE_FOCUS); + if (presContext) { + nsCOMPtr esm; + presContext->GetEventStateManager(getter_AddRefs(esm)); + if (esm) { + // XXX Fix for bug 135345 - ESM currently does not check to see if we + // have focus before attempting to set focus again and may cause + // infinite recursion. For now check if we have focus and do not set + // focus again if already focused. + PRInt32 currentState; + esm->GetContentState(this, currentState); + if (!(currentState & NS_EVENT_STATE_FOCUS)) { + esm->SetContentState(this, NS_EVENT_STATE_FOCUS); + } } }