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;