From 7d07b23bb4e06d58c38e423dcbf8b119878c6c17 Mon Sep 17 00:00:00 2001 From: "edburns%acm.org" Date: Wed, 26 Jul 2000 01:03:25 +0000 Subject: [PATCH] bug=41871 a=edburns r=ashuk This checkin makes it so CBrowserContainer is properly released. The problem was that the CBrowserContainer was still registered to the docShell as a listener. The solution was to call wcIBrowserContianer::RemoveAllListeners() in the WebShellInitContext deallocator. git-svn-id: svn://10.0.0.236/trunk@74788 18797224-902f-48f8-a5cc-f745e15eee43 --- .../webclient/src_moz/CBrowserContainer.cpp | 14 ++++++++- mozilla/java/webclient/src_moz/nsActions.cpp | 30 +++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/mozilla/java/webclient/src_moz/CBrowserContainer.cpp b/mozilla/java/webclient/src_moz/CBrowserContainer.cpp index 9839dd3e299..a9ded31b59b 100644 --- a/mozilla/java/webclient/src_moz/CBrowserContainer.cpp +++ b/mozilla/java/webclient/src_moz/CBrowserContainer.cpp @@ -103,12 +103,24 @@ CBrowserContainer::CBrowserContainer(nsIWebBrowser *pOwner, JNIEnv *env, if (nsnull == gVm) { // declared in jni_util.h ::util_GetJavaVM(env, &gVm); // save this vm reference away for the callback! } - } CBrowserContainer::~CBrowserContainer() { + m_pOwner = nsnull; + mJNIEnv = nsnull; + mInitContext = nsnull; + mDocTarget = nsnull; + mMouseTarget = nsnull; + mDomEventTarget = nsnull; + inverseDepth = -1; + JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION_1_2); + if (properties) { + ::util_DeleteGlobalRef(env, properties); + } + properties = nsnull; + currentDOMEvent = nsnull; } diff --git a/mozilla/java/webclient/src_moz/nsActions.cpp b/mozilla/java/webclient/src_moz/nsActions.cpp index c47eb96bf7f..c05221e46ab 100644 --- a/mozilla/java/webclient/src_moz/nsActions.cpp +++ b/mozilla/java/webclient/src_moz/nsActions.cpp @@ -35,6 +35,7 @@ #include "nsIBaseWindow.h" #include "nsISHEntry.h" #include "nsIURI.h" +#include "nsIDocShellTreeItem.h" #include "jni_util.h" @@ -680,9 +681,29 @@ wsDeallocateInitContextEvent::handleEvent () } mInitContext->parentHWnd = nsnull; - // ((nsISupports *)mInitContext->docShell)->Release(); + + // make sure the webBrowser's contentListener doesn't have a ref to + // CBrowserContainer + mInitContext->webBrowser->SetParentURIContentListener(nsnull); + mInitContext->webBrowser = nsnull; + + // make sure the webShell's container is set to null. + // get the webShell from the docShell + nsCOMPtr webShell(do_QueryInterface(mInitContext->docShell)); + if (webShell) { + webShell->SetContainer(nsnull); + } + + // make sure the docShell's TreeOwner is set to null + // get the docShellTreeItem from the docShell + nsCOMPtr docShellAsItem(do_QueryInterface(mInitContext->docShell)); + if (docShellAsItem) { + docShellAsItem->SetTreeOwner(nsnull); + } + + mInitContext->docShell->SetDocLoaderObserver(nsnull); + mInitContext->docShell = nsnull; - // ((nsISupports *)mInitContext->webShell)->Release(); // PENDING(edburns): this is a leak. For some reason, webShell's // refcount is two. I believe it should be one. @@ -710,6 +731,11 @@ wsDeallocateInitContextEvent::handleEvent () mInitContext->h = -1; mInitContext->gtkWinPtr = nsnull; mInitContext->searchContext = nsnull; + + // make sure we aren't listening anymore. This needs to be done + // before currentDocument = nsnull + mInitContext->browserContainer->RemoveAllListeners(); + mInitContext->currentDocument = nsnull; mInitContext->propertiesClass = nsnull; mInitContext->browserContainer = nsnull;