Bug 586808 - Incubator embedding: MozView crashes on destroy if page is not loaded [@ WebBrowserChrome::OnStateChange]. r=mark.finkle
authorTatiana Meshkova <tanya.meshkova@gmail.com>
Tue, 17 Aug 2010 10:42:15 -0700
changeset 124 8826f3cba2b00ee569df8b21359d63865abad6fc
parent 123 ee3722ecb5228f114c4eb8f0466748bcb5fb834f
child 125 607aad0e0aeacb5191d0af3617b745e54cbd384a
push id38
push userromaxa@gmail.com
push dateWed, 18 Aug 2010 17:43:40 +0000
reviewersmark.finkle
bugs586808
Bug 586808 - Incubator embedding: MozView crashes on destroy if page is not loaded [@ WebBrowserChrome::OnStateChange]. r=mark.finkle
common/embed.cpp
--- a/common/embed.cpp
+++ b/common/embed.cpp
@@ -19,16 +19,17 @@
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Pelle Johnsen <pjohnsen@mozilla.com>
  *   Dave Camp <dcamp@mozilla.com>
  *   Tobias Hunger <tobias.hunger@gmail.com>
  *   Steffen Imhof <steffen.imhof@googlemail.com>
  *   Anton Rogaynis <wildriding@gmail.com>
+ *   Tatiana Meshkova <tanya.meshkova@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -170,16 +171,23 @@ public:
     ~Private()
     {
         nsCOMPtr<nsIConsoleService> consoleService(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
         if (!consoleService)
             cerr << "Failed to get Console service!" << endl;
         else if (NS_FAILED(consoleService->UnregisterListener(mConsoleListener)))
             cerr << "Failed to unregister console listener." << endl;
 
+        // disconnect listener before window destroy
+        nsCOMPtr<nsIWebProgressListener> listener = do_QueryInterface(mChrome);
+        nsCOMPtr<nsIWeakReference> thisListener(do_GetWeakReference(listener));
+        if (mWebBrowser)
+            mWebBrowser->RemoveWebBrowserListener(thisListener, NS_GET_IID(nsIWebProgressListener));
+        thisListener = nsnull;
+
         if (mChrome)
             mChrome->SetWebBrowser(0);
         if (mWebBrowser) {
             mWebBrowser->SetParentURIContentListener(0);
 
             nsCOMPtr<nsIBaseWindow> baseWindow;
             baseWindow = do_QueryInterface(mWebBrowser);
             if (baseWindow)