Rearrange the code so that windows can be closed programmatically, and deregistration etc all happens, in a more foolproof way.

This commit is contained in:
mcmullen%netscape.com 1999-03-27 00:09:04 +00:00
Родитель 43d656ab19
Коммит 607708bd0f
2 изменённых файлов: 17 добавлений и 23 удалений

Просмотреть файл

@ -255,14 +255,7 @@ nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *aParent,
NS_IMETHODIMP
nsAppShellService::CloseTopLevelWindow(nsIWebShellWindow* aWindow)
{
nsresult closerv, unregrv;
closerv = aWindow->Close();
unregrv = UnregisterTopLevelWindow(aWindow);
if (0 == mWindowList->Count())
mAppShell->Exit();
return closerv == NS_OK ? unregrv : closerv;
return aWindow->Close();
}
/*
@ -331,6 +324,8 @@ nsAppShellService::UnregisterTopLevelWindow(nsIWebShellWindow* aWindow)
mWindowList->RemoveElement(wsc);
NS_RELEASE(wsc);
}
if (0 == mWindowList->Count())
mAppShell->Exit();
return rv;
}

Просмотреть файл

@ -311,7 +311,16 @@ nsWebShellWindow::Close()
Revisit this later!?
*/
// Release();
return NS_OK;
nsIAppShellService* appShell;
nsresult rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (NS_FAILED(rv))
return rv;
rv = appShell->UnregisterTopLevelWindow(this);
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
return rv;
}
@ -324,7 +333,6 @@ nsWebShellWindow::Close()
nsEventStatus PR_CALLBACK
nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
{
nsresult rv;
nsEventStatus result = nsEventStatus_eIgnore;
nsIWebShell* webShell = nsnull;
@ -354,19 +362,10 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
* Notify the ApplicationShellService that the window is being closed...
*/
case NS_DESTROY: {
nsIAppShellService* appShell;
rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
if (NS_SUCCEEDED(rv)) {
void *data;
void* data;
aEvent->widget->GetClientData(data);
if (data != nsnull)
appShell->CloseTopLevelWindow((nsWebShellWindow *)data);
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
}
if (data)
((nsWebShellWindow *)data)->Close();
break;
}
}