Bug 517768 - crash with view page source and external editor [@nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, unsigned int) ]. r=bz
authorDão Gottwald <dao@mozilla.com>
Fri, 02 Oct 2009 20:33:55 +0200
changeset 33129 12a923071ba80b6b6dee9635c4ed873bfa519c1c
parent 33128 9a9e3daf759ca592d73703c747adab9a590c8a69
child 33130 ce1974a8acb6ac247da1ac28d3b0f2580b0a7371
push id798
push userdgottwald@mozilla.com
push dateTue, 24 Nov 2009 20:42:48 +0000
reviewersbz
bugs517768
milestone1.9.2b4pre
Bug 517768 - crash with view page source and external editor [@nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, unsigned int) ]. r=bz
toolkit/components/viewsource/content/viewSourceUtils.js
--- a/toolkit/components/viewsource/content/viewSourceUtils.js
+++ b/toolkit/components/viewsource/content/viewSourceUtils.js
@@ -136,16 +136,17 @@ var gViewSourceUtils = {
                     .deleteTemporaryFileOnExit(file);
         } else {
           // we'll use nsIWebPageDescriptor to get the source because it may
           // not have to refetch the file from the server
           // XXXbz this is so broken...  This code doesn't set up this docshell
           // at all correctly; if somehow the view-source stuff managed to
           // execute script we'd be in big trouble here, I suspect.
           var webShell = Components.classes["@mozilla.org/docshell;1"].createInstance();
+          webShell.QueryInterface(Components.interfaces.nsIBaseWindow).create();
           this.viewSourceProgressListener.webShell = webShell;
           var progress = webShell.QueryInterface(this.mnsIWebProgress);
           progress.addProgressListener(this.viewSourceProgressListener,
                                        this.mnsIWebProgress.NOTIFY_STATE_DOCUMENT);
           var pageLoader = webShell.QueryInterface(this.mnsIWebPageDescriptor);    
           pageLoader.loadPage(aPageDescriptor, this.mnsIWebPageDescriptor.DISPLAY_AS_SOURCE);
         }
       }
@@ -209,21 +210,22 @@ var gViewSourceUtils = {
      if (aIID.equals(this.mnsIWebProgressListener) ||
          aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
          aIID.equals(Components.interfaces.nsISupports))
        return this;
      throw Components.results.NS_NOINTERFACE;
     },
 
     destroy: function() {
-        this.webShell = null;
-        this.editor = null;
-        this.callBack = null;
-        this.data = null;
-        this.file = null;
+      this.webShell.QueryInterface(Components.interfaces.nsIBaseWindow).destroy();
+      this.webShell = null;
+      this.editor = null;
+      this.callBack = null;
+      this.data = null;
+      this.file = null;
     },
 
     onStateChange: function(aProgress, aRequest, aFlag, aStatus) {
       // once it's done loading...
       if ((aFlag & this.mnsIWebProgressListener.STATE_STOP) && aStatus == 0) {
         try {
           if (!this.file) {
             // it's not saved to file yet, it's in the webshell