diff --git a/mailnews/base/src/nsMsgStatusFeedback.cpp b/mailnews/base/src/nsMsgStatusFeedback.cpp index 5be33f9ed484..c199cf3ea708 100644 --- a/mailnews/base/src/nsMsgStatusFeedback.cpp +++ b/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/mailnews/base/src/nsMsgStatusFeedback.h b/mailnews/base/src/nsMsgStatusFeedback.h index b37d86ca9eb3..ff15330d89b5 100644 --- a/mailnews/base/src/nsMsgStatusFeedback.h +++ b/mailnews/base/src/nsMsgStatusFeedback.h @@ -63,7 +63,7 @@ protected: PRBool mQueuedMeteorStops; nsCOMPtr mStartTimer; nsCOMPtr mStopTimer; - + void BeginObserving(); void EndObserving(); diff --git a/mailnews/base/src/nsMsgWindow.cpp b/mailnews/base/src/nsMsgWindow.cpp index 985ea24e4444..60bbbef73c04 100644 --- a/mailnews/base/src/nsMsgWindow.cpp +++ b/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)