Fixing part of bug 104297. Making calling window.close() on an already closed window not throw exceptions and not assert. r=jaggernaut@netscape.com, sr=sfraser@netscape.com

git-svn-id: svn://10.0.0.236/trunk@105480 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%netscape.com 2001-10-16 06:38:04 +00:00
parent da2e2dc828
commit 58fc31825f

View File

@ -2451,10 +2451,13 @@ GlobalWindowImpl::ReallyCloseWindow()
{
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
NS_ENSURE_TRUE(treeOwnerAsWin, NS_ERROR_FAILURE);
treeOwnerAsWin->Destroy();
CleanUp();
// If there's no treeOwnerAsWin, this window must already be closed.
if (treeOwnerAsWin) {
treeOwnerAsWin->Destroy();
CleanUp();
}
return NS_OK;
}
@ -4003,7 +4006,15 @@ nsresult
GlobalWindowImpl::GetTreeOwner(nsIDocShellTreeOwner **aTreeOwner)
{
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
// If there's no docShellAsItem, this window must have been closed,
// in that case there is no tree owner.
if (!docShellAsItem) {
*aTreeOwner = nsnull;
return NS_OK;
}
return docShellAsItem->GetTreeOwner(aTreeOwner);
}
@ -4012,10 +4023,15 @@ nsresult
GlobalWindowImpl::GetTreeOwner(nsIBaseWindow **aTreeOwner)
{
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mDocShell));
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
// If there's no docShellAsItem, this window must have been closed,
// in that case there is no tree owner.
if (docShellAsItem) {
docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
}
if (!treeOwner) {
*aTreeOwner = nsnull;
return NS_OK;