diff --git a/mailnews/base/src/nsMsgAccountManager.cpp b/mailnews/base/src/nsMsgAccountManager.cpp index 9412c9322ae3..2d1febda728d 100644 --- a/mailnews/base/src/nsMsgAccountManager.cpp +++ b/mailnews/base/src/nsMsgAccountManager.cpp @@ -118,6 +118,7 @@ public: NS_IMETHOD GetAllServers(nsISupportsArray **_retval) ; NS_IMETHOD LoadAccounts(); + NS_IMETHOD UnloadAccounts(); NS_IMETHOD FindServer(const char* username, const char* hostname, @@ -191,12 +192,9 @@ nsMsgAccountManager::nsMsgAccountManager() : nsMsgAccountManager::~nsMsgAccountManager() { - // release the default account - m_defaultAccount=nsnull; if (m_prefs) nsServiceManager::ReleaseService(kPrefServiceCID, m_prefs); - m_accounts->Enumerate(hashTableRemoveAccountFromBiff, this); - m_accounts->Enumerate(hashTableRemoveAccount, this); + UnloadAccounts(); delete m_accounts; } @@ -503,11 +501,9 @@ nsMsgAccountManager::hashTableRemoveAccount(nsHashKey *aKey, void *aData, void*closure) { nsIMsgAccount* account = (nsIMsgAccount*)aData; - nsMsgAccountManager* accountManager = (nsMsgAccountManager*) closure; // remove from hashtable NS_RELEASE(account); - accountManager->m_accounts->Remove(aKey); return PR_TRUE; } @@ -690,6 +686,18 @@ nsMsgAccountManager::LoadAccounts() return NS_OK; } +nsresult +nsMsgAccountManager::UnloadAccounts() +{ + // release the default account + m_defaultAccount=nsnull; + m_accounts->Enumerate(hashTableRemoveAccountFromBiff, this); + m_accounts->Enumerate(hashTableRemoveAccount, this); + m_accounts->Reset(); + m_accountsLoaded = PR_FALSE; + return NS_OK; +} + nsIMsgAccount * nsMsgAccountManager::LoadAccount(nsString& accountKey) { diff --git a/mailnews/base/src/nsMsgMailSession.cpp b/mailnews/base/src/nsMsgMailSession.cpp index da0873b50fc9..aae1216f4e4e 100644 --- a/mailnews/base/src/nsMsgMailSession.cpp +++ b/mailnews/base/src/nsMsgMailSession.cpp @@ -54,6 +54,9 @@ nsMsgMailSession::nsMsgMailSession(): nsMsgMailSession::~nsMsgMailSession() { + if(m_accountManager) + m_accountManager->UnloadAccounts(); + NS_IF_RELEASE(m_accountManager); if (mListeners)