Bug 573388 ASSERTION: aWebProgress and channel callbacks do not point to the same docshell r=bienvenu sr=Standard8
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Wed, 03 Nov 2010 00:00:08 +0000
changeset 6635 e9aa02dcfc2dba20de52e29edfd87c7506f4fa8e
parent 6634 fcf9a22d240fe4de6fa010ad79740ab06d46925a
child 6636 b71a8499c3ec15a8c07f5ca5e459d4ee1ca37d7a
push idunknown
push userunknown
push dateunknown
reviewersbienvenu, Standard8
bugs573388
Bug 573388 ASSERTION: aWebProgress and channel callbacks do not point to the same docshell r=bienvenu sr=Standard8
mailnews/base/public/nsIMsgWindow.idl
mailnews/base/src/nsMsgWindow.cpp
mailnews/base/src/nsMsgWindow.h
mailnews/imap/src/nsImapProtocol.cpp
--- a/mailnews/base/public/nsIMsgWindow.idl
+++ b/mailnews/base/public/nsIMsgWindow.idl
@@ -48,31 +48,38 @@ interface nsIInterfaceRequestor;
 
 [scriptable, uuid(7B8F4A65-CFC4-4b3f-BF5C-152AA8D5CD10)]
 interface nsIMsgWindowCommands : nsISupports {
   void selectFolder(in ACString folderUri);
   void selectMessage(in ACString messageUri);
   void clearMsgPane();
 };
 
-[scriptable, uuid(7e8fbaaa-d2f1-4751-af8e-8213fdb60a03)]
+[scriptable, uuid(8ad06f07-2230-4917-968c-2269588dbf7d)]
 interface nsIMsgWindow : nsISupports {
   attribute nsIMsgStatusFeedback statusFeedback;
   attribute nsIMsgWindowCommands windowCommands;
   attribute nsIMsgHeaderSink msgHeaderSink;
   attribute nsITransactionManager transactionManager;
   attribute nsIMsgFolder openFolder;
   
   /**
    * @note Setting this attribute has various side effects, including
    * wiring up this object as the parent nsIURIContentListener for the
    * passed-in docshell as well as setting the message content policy service
    * to listen for OnLocationChange notifications.
    */
   attribute nsIDocShell rootDocShell;
+
+  /**
+   * @note Small helper function used to optimize our use of a weak reference
+   * on the message window docshell. Under no circumstances should you be
+   * holding on to the docshell returned here outside the scope of your routine.
+   */
+  readonly attribute nsIDocShell messageWindowDocShell;
   
   /**
    * These are currently used to set notification callbacks on
    * protocol channels to handle things like bad cert exceptions.
    */
   attribute nsIInterfaceRequestor notificationCallbacks;
   
   void displayHTMLInMessagePane(in AString title, in AString body, in boolean clearMsgHdr);
--- a/mailnews/base/src/nsMsgWindow.cpp
+++ b/mailnews/base/src/nsMsgWindow.cpp
@@ -101,37 +101,40 @@ nsresult nsMsgWindow::Init()
     return rv;
 
   // create Undo/Redo Transaction Manager
   mTransactionManager = do_CreateInstance(kTransactionManagerCID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
   return mTransactionManager->SetMaxTransactionCount(-1);
 }
 
-void nsMsgWindow::GetMessageWindowDocShell(nsIDocShell ** aDocShell)
+NS_IMETHODIMP nsMsgWindow::GetMessageWindowDocShell(nsIDocShell ** aDocShell)
 {
+  *aDocShell = nsnull;
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mMessageWindowDocShellWeak));
   if (!docShell)
   {
     // if we don't have a docshell, then we need to look up the message pane docshell
     nsCOMPtr<nsIDocShell> rootShell(do_QueryReferent(mRootDocShellWeak));
     if (rootShell)
     {
       nsCOMPtr<nsIDocShellTreeNode> rootAsNode(do_QueryInterface(rootShell));
       nsCOMPtr<nsIDocShellTreeItem> msgDocShellItem;
       if(rootAsNode)
          rootAsNode->FindChildWithName(NS_LITERAL_STRING("messagepane").get(),
                                        PR_TRUE, PR_FALSE, nsnull, nsnull,
                                        getter_AddRefs(msgDocShellItem));
+      NS_ENSURE_TRUE(msgDocShellItem, NS_ERROR_FAILURE);
       docShell = do_QueryInterface(msgDocShellItem);
       // we don't own mMessageWindowDocShell so don't try to keep a reference to it!
       mMessageWindowDocShellWeak = do_GetWeakReference(docShell);
     }
   }
   docShell.swap(*aDocShell);
+  return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgWindow::CloseWindow()
 {
   nsresult rv = NS_OK;
   nsCOMPtr<nsIURILoader> dispatcher = do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
   if (dispatcher) // on shut down it's possible dispatcher will be null.
     rv = dispatcher->UnRegisterContentListener(this);
--- a/mailnews/base/src/nsMsgWindow.h
+++ b/mailnews/base/src/nsMsgWindow.h
@@ -77,15 +77,11 @@ protected:
   // let's not make this a strong ref - we don't own it.
   nsWeakPtr mRootDocShellWeak;
   nsWeakPtr mMessageWindowDocShellWeak;
   nsWeakPtr mDomWindow; 
 
   nsCString mMailCharacterSet;
   PRBool    mCharsetOverride;
   PRBool    m_stopped;
-  // small helper function used to optimize our use of a weak reference
-  // on the message window docshell. Under no circumstances should you be holding on to
-  // the docshell returned here outside the scope of your routine.
-  void GetMessageWindowDocShell(nsIDocShell ** aDocShell);
 };
 
 #endif
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -772,17 +772,17 @@ nsresult nsImapProtocol::SetupWithUrl(ns
       m_mockChannel->GetChannelContext(getter_AddRefs(m_channelContext));
       nsCOMPtr<nsIMsgWindow> msgWindow;
       GetMsgWindow(getter_AddRefs(msgWindow));
       if (!msgWindow)
         GetTopmostMsgWindow(getter_AddRefs(msgWindow));
       if (msgWindow)
       {
         nsCOMPtr<nsIDocShell> docShell;
-        msgWindow->GetRootDocShell(getter_AddRefs(docShell));
+        msgWindow->GetMessageWindowDocShell(getter_AddRefs(docShell));
         nsCOMPtr<nsIInterfaceRequestor> ir(do_QueryInterface(docShell));
         nsCOMPtr<nsIInterfaceRequestor> interfaceRequestor;
         msgWindow->GetNotificationCallbacks(getter_AddRefs(interfaceRequestor));
         nsCOMPtr<nsIInterfaceRequestor> aggregateIR;
         NS_NewInterfaceRequestorAggregation(interfaceRequestor, ir, getter_AddRefs(aggregateIR));
         m_mockChannel->SetNotificationCallbacks(aggregateIR);
       }
     }