Added GetBrowserWindow to nsWebCrawler, and changed nsViewerApp to only

call SetBrowserWindow() once and to have CloseWindow() check before
setting the web crawler's browser window to NULL (doing so caused a crash)
This commit is contained in:
troy%netscape.com 1999-02-19 04:24:12 +00:00
Родитель 0bc7b91473
Коммит 42e8139d31
3 изменённых файлов: 22 добавлений и 4 удалений

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

@ -584,7 +584,12 @@ nsViewerApp::OpenWindow()
bw->SetApp(this);
bw->Init(mAppShell, mPrefs, nsRect(0, 0, 620, 400), PRUint32(~0), mAllowPlugins);
bw->Show();
mCrawler->SetBrowserWindow(bw);
nsIBrowserWindow* bwCurrent;
mCrawler->GetBrowserWindow(&bwCurrent);
if (!bwCurrent) {
mCrawler->SetBrowserWindow(bw);
}
NS_IF_RELEASE(bwCurrent);
if (mDoPurify) {
for (PRInt32 i = 0; i < mRepeatCount; i++) {
@ -617,9 +622,14 @@ nsViewerApp::OpenWindow()
NS_IMETHODIMP
nsViewerApp::CloseWindow(nsBrowserWindow* aBrowserWindow)
{
aBrowserWindow->Close();
NS_RELEASE(aBrowserWindow);
mCrawler->SetBrowserWindow(nsnull);
aBrowserWindow->Close();
nsIBrowserWindow* bw;
mCrawler->GetBrowserWindow(&bw);
if (bw == aBrowserWindow) {
mCrawler->SetBrowserWindow(nsnull);
}
NS_IF_RELEASE(bw);
NS_RELEASE(aBrowserWindow);
return NS_OK;
}

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

@ -662,6 +662,13 @@ nsWebCrawler::SetBrowserWindow(nsIBrowserWindow* aWindow)
NS_IF_ADDREF(mBrowser);
}
void
nsWebCrawler::GetBrowserWindow(nsIBrowserWindow** aWindow)
{
NS_IF_ADDREF(mBrowser);
*aWindow = mBrowser;
}
static void
TimerCallBack(nsITimer *aTimer, void *aClosure)
{

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

@ -58,6 +58,7 @@ public:
void AddAvoidDomain(const nsString& aDomain);
void SetBrowserWindow(nsIBrowserWindow* aWindow);
void GetBrowserWindow(nsIBrowserWindow** aWindow);
// Set the delay (by default, the timer is set to one second)
void SetDelay(PRInt32 aSeconds) {