From fa915ef4cb0d1827f955dcd1f372d4eae6ad6536 Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Wed, 16 Feb 2000 05:33:05 +0000 Subject: [PATCH] Bug #25583,27681,24193 --> add a close window argument and null out our weak reference to the webshell. this workaround is necessary because of some nasty leaks in the mailnews 3pane which causes the feedback object to be leaked so it's still around when the webshell has been destroyed. r=sspitzer git-svn-id: svn://10.0.0.236/trunk@61071 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mailnews/base/src/nsMsgStatusFeedback.cpp | 29 ++++++++++++++----- .../mailnews/base/src/nsMsgStatusFeedback.h | 2 +- mozilla/mailnews/base/src/nsMsgWindow.cpp | 20 ++++++++++--- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp b/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp index 5be33f9ed48..c199cf3ea70 100644 --- a/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp +++ b/mozilla/mailnews/base/src/nsMsgStatusFeedback.cpp @@ -152,9 +152,9 @@ void nsMsgStatusFeedback::BeginObserving() nsAutoString topic1(prefix); topic1 += ";status"; rv = svc->AddObserver( this, topic1.GetUnicode() ); - } + } - return; + return; } void nsMsgStatusFeedback::EndObserving() @@ -308,18 +308,27 @@ nsMsgStatusFeedback::StopMeteors() return NS_OK; } +NS_IMETHODIMP nsMsgStatusFeedback::CloseWindow() +{ + EndObserving(); + mWindow = nsnull; + mWebShell = nsnull; + mWebShellWindow = nsnull; + + return NS_OK; +} NS_IMETHODIMP nsMsgStatusFeedback::SetWebShell(nsIWebShell *shell, nsIDOMWindow *aWindow) { if (aWindow) { nsCOMPtr - globalScript(do_QueryInterface(aWindow)); - nsCOMPtr docShell; + globalScript(do_QueryInterface(aWindow)); + nsCOMPtr docShell; if (globalScript) globalScript->GetDocShell(getter_AddRefs(docShell)); nsCOMPtr webshell(do_QueryInterface(docShell)); - nsCOMPtr rootWebshell; + nsCOMPtr rootWebshell; if (webshell) { webshell->GetRootWebShell(mWebShell); @@ -348,7 +357,11 @@ static int debugSetAttr = 0; nsresult nsMsgStatusFeedback::setAttribute( nsIWebShell *shell, const char *id, const char *name, - const nsString &value ) { + const nsString &value ) +{ + if (!mWebShell) + return NS_OK; + nsresult rv = NS_OK; nsCOMPtr cv; @@ -365,7 +378,7 @@ nsresult nsMsgStatusFeedback::setAttribute( nsIWebShell *shell, // Up-cast. nsCOMPtr xulDoc( do_QueryInterface(doc) ); if ( xulDoc ) - { + { // Find specified element. nsCOMPtr elem; rv = xulDoc->GetElementById( id, getter_AddRefs(elem) ); @@ -374,7 +387,7 @@ nsresult nsMsgStatusFeedback::setAttribute( nsIWebShell *shell, rv = elem->SetAttribute( name, value ); if ( debugSetAttr ) { char *p = value.ToNewCString(); - printf("setting busy to %s\n", p); + printf("setting busy to %s\n", p); delete [] p; } if ( rv != NS_OK ) { diff --git a/mozilla/mailnews/base/src/nsMsgStatusFeedback.h b/mozilla/mailnews/base/src/nsMsgStatusFeedback.h index b37d86ca9eb..ff15330d89b 100644 --- a/mozilla/mailnews/base/src/nsMsgStatusFeedback.h +++ b/mozilla/mailnews/base/src/nsMsgStatusFeedback.h @@ -63,7 +63,7 @@ protected: PRBool mQueuedMeteorStops; nsCOMPtr mStartTimer; nsCOMPtr mStopTimer; - + void BeginObserving(); void EndObserving(); diff --git a/mozilla/mailnews/base/src/nsMsgWindow.cpp b/mozilla/mailnews/base/src/nsMsgWindow.cpp index 985ea24e444..60bbbef73c0 100644 --- a/mozilla/mailnews/base/src/nsMsgWindow.cpp +++ b/mozilla/mailnews/base/src/nsMsgWindow.cpp @@ -48,10 +48,7 @@ nsMsgWindow::nsMsgWindow() nsMsgWindow::~nsMsgWindow() { - nsresult rv = NS_OK; - NS_WITH_SERVICE(nsIURILoader, dispatcher, NS_URI_LOADER_PROGID, &rv); - if (NS_SUCCEEDED(rv)) - rv = dispatcher->UnRegisterContentListener(this); + CloseWindow(); } nsresult nsMsgWindow::Init() @@ -77,6 +74,21 @@ nsresult nsMsgWindow::Init() return rv; } +NS_IMETHODIMP nsMsgWindow::CloseWindow() +{ + nsresult rv = NS_OK; + NS_WITH_SERVICE(nsIURILoader, dispatcher, NS_URI_LOADER_PROGID, &rv); + if (NS_SUCCEEDED(rv)) + rv = dispatcher->UnRegisterContentListener(this); + + // make sure the status feedback object + // knows the window is going away... + if (mStatusFeedback) + mStatusFeedback->CloseWindow(); + + return NS_OK; +} + NS_IMETHODIMP nsMsgWindow::GetStatusFeedback(nsIMsgStatusFeedback * *aStatusFeedback) { if(!aStatusFeedback)