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 33394 72eb60dd0f50b3fe1cbcba8e2e4796ed65d747a6
parent 33393 e9d59855daf92746f2dc78b7f78620091916e4f8
child 33395 0f0239688a76c6a992598b57a4e67bfc45793e19
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs517768
milestone1.9.3a1pre
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