Bug 612447 - Part 3: Prevent the HTML editor from dying while we run a document modified handler from a script runner; r=bzbarsky a=blocking-beta8
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 19 Nov 2010 11:02:24 -0500
changeset 57960 70116ee1ea9a56be36377a6a067c73c4ffeec2af
parent 57959 406748270073ffdf35ccb1a203943751c38a4a37
child 57961 0012ca751ce10ec068e538e4e3759efcc0000398
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersbzbarsky, blocking-beta8
bugs612447
milestone2.0b8pre
Bug 612447 - Part 3: Prevent the HTML editor from dying while we run a document modified handler from a script runner; r=bzbarsky a=blocking-beta8
editor/libeditor/html/nsHTMLEditRules.cpp
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -9166,16 +9166,18 @@ nsHTMLEditRules::DocumentModified()
 {
   nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, &nsHTMLEditRules::DocumentModifiedWorker));
   return NS_OK;
 }
 
 void
 nsHTMLEditRules::DocumentModifiedWorker()
 {
+  nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(mHTMLEditor);
+
   nsCOMPtr<nsISelection> selection;
   nsresult res = mHTMLEditor->GetSelection(getter_AddRefs(selection));
   NS_ENSURE_SUCCESS(res, );
 
   // Delete our bogus node, if we have one, since the document might not be
   // empty any more.
   if (mBogusNode) {
     mEditor->DeleteNode(mBogusNode);