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
This commit is contained in:
mscott%netscape.com
2000-02-16 05:33:05 +00:00
parent 868f4df92b
commit fa915ef4cb
3 changed files with 38 additions and 13 deletions

View File

@@ -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<nsIScriptGlobalObject>
globalScript(do_QueryInterface(aWindow));
nsCOMPtr<nsIDocShell> docShell;
globalScript(do_QueryInterface(aWindow));
nsCOMPtr<nsIDocShell> docShell;
if (globalScript)
globalScript->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIWebShell> webshell(do_QueryInterface(docShell));
nsCOMPtr<nsIWebShell> rootWebshell;
nsCOMPtr<nsIWebShell> 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<nsIContentViewer> cv;
@@ -365,7 +378,7 @@ nsresult nsMsgStatusFeedback::setAttribute( nsIWebShell *shell,
// Up-cast.
nsCOMPtr<nsIDOMXULDocument> xulDoc( do_QueryInterface(doc) );
if ( xulDoc )
{
{
// Find specified element.
nsCOMPtr<nsIDOMElement> 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 ) {

View File

@@ -63,7 +63,7 @@ protected:
PRBool mQueuedMeteorStops;
nsCOMPtr<nsITimer> mStartTimer;
nsCOMPtr<nsITimer> mStopTimer;
void BeginObserving();
void EndObserving();

View File

@@ -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)