From b520ce68a98a4dc9fc160c9b1d711ed2e69709e1 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Sun, 18 Jan 2004 04:35:54 +0000 Subject: [PATCH] Don't crash if the file input's frame is destroyed while the filepicker is up. Bug 230998, r+sr=dbaron git-svn-id: svn://10.0.0.236/trunk@151481 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsFileControlFrame.cpp | 6 ++++++ mozilla/layout/html/forms/src/nsFileControlFrame.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp index 8ff6c1e7468..83289aa1032 100644 --- a/mozilla/layout/forms/nsFileControlFrame.cpp +++ b/mozilla/layout/forms/nsFileControlFrame.cpp @@ -131,6 +131,7 @@ nsFileControlFrame::Destroy(nsIPresContext* aPresContext) nsCOMPtr fileInput = do_QueryInterface(mContent); fileInput->TakeTextFrameValue(value); } + mTextFrame = nsnull; return nsAreaFrame::Destroy(aPresContext); } @@ -324,6 +325,11 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent) if (mode == nsIFilePicker::returnCancel) return NS_OK; + if (!mTextFrame) { + // We got destroyed while the filepicker was up. Don't do anything here. + return NS_OK; + } + // Set property nsCOMPtr localFile; result = filePicker->GetFile(getter_AddRefs(localFile)); diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp index 8ff6c1e7468..83289aa1032 100644 --- a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp @@ -131,6 +131,7 @@ nsFileControlFrame::Destroy(nsIPresContext* aPresContext) nsCOMPtr fileInput = do_QueryInterface(mContent); fileInput->TakeTextFrameValue(value); } + mTextFrame = nsnull; return nsAreaFrame::Destroy(aPresContext); } @@ -324,6 +325,11 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent) if (mode == nsIFilePicker::returnCancel) return NS_OK; + if (!mTextFrame) { + // We got destroyed while the filepicker was up. Don't do anything here. + return NS_OK; + } + // Set property nsCOMPtr localFile; result = filePicker->GetFile(getter_AddRefs(localFile));