diff --git a/webshell/tests/viewer/nsViewerApp.cpp b/webshell/tests/viewer/nsViewerApp.cpp index 4f78f35601d..a48b4457e39 100644 --- a/webshell/tests/viewer/nsViewerApp.cpp +++ b/webshell/tests/viewer/nsViewerApp.cpp @@ -157,12 +157,23 @@ nsViewerApp::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) void nsViewerApp::Destroy() { + nsresult rv; + // Close all of our windows nsBrowserWindow::CloseAllWindows(); // Release the crawler - NS_IF_RELEASE(mCrawler); + if (nsnull != mCrawler) { + // break cycle between crawler and window. + mCrawler->SetBrowserWindow(nsnull); + NS_RELEASE(mCrawler); + } + NS_WITH_SERVICE(nsIMetaCharsetService, metacharset, kMetaCharsetCID, &rv); + if (NS_SUCCEEDED(rv)) { + rv = metacharset->End(); + } + #ifndef NECKO // Only shutdown if Initialize has been called... if (PR_TRUE == mIsInitialized) { @@ -193,18 +204,11 @@ nsViewerApp::SetupRegistry() NS_SetupRegistry(); - nsIMetaCharsetService* metacharset; - rv = nsServiceManager::GetService(kMetaCharsetCID, - kIMetaCharsetServiceIID, - (nsISupports **) &metacharset); - if(!NS_FAILED(rv)) { + NS_WITH_SERVICE(nsIMetaCharsetService, metacharset, kMetaCharsetCID, &rv); + if (NS_SUCCEEDED(rv)) { rv = metacharset->Start(); } - if(!NS_FAILED(rv)) { - rv = nsServiceManager::ReleaseService(kMetaCharsetCID, metacharset); - } - // Register our browser window factory nsIFactory* bwf; NS_NewBrowserWindowFactory(&bwf);