From 0388215cbb0949029b7c97d80034e374ac6c59f0 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Thu, 18 Apr 2002 22:01:00 +0000 Subject: [PATCH] fix for #134743. Turbo on, mailing list entries duplicated after an exit/restart. r=racham, sr=bienvenu. git-svn-id: svn://10.0.0.236/trunk@119315 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mailnews/addrbook/src/nsAbDirProperty.cpp | 9 ++++++++ .../addrbook/src/nsAbMDBDirProperty.cpp | 4 ++-- .../mailnews/addrbook/src/nsAddrDatabase.cpp | 23 ++++++++++++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/mozilla/mailnews/addrbook/src/nsAbDirProperty.cpp b/mozilla/mailnews/addrbook/src/nsAbDirProperty.cpp index bbdcbf4846e..3d2fa0f65d6 100644 --- a/mozilla/mailnews/addrbook/src/nsAbDirProperty.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbDirProperty.cpp @@ -62,6 +62,15 @@ nsAbDirProperty::nsAbDirProperty(void) nsAbDirProperty::~nsAbDirProperty(void) { + if (m_AddressList) { + PRUint32 count; + nsresult rv; + rv = m_AddressList->Count(&count); + NS_ASSERTION(NS_SUCCEEDED(rv), "Count failed"); + PRInt32 i; + for (i = count - 1; i >= 0; i--) + m_AddressList->RemoveElementAt(i); + } } NS_IMPL_ISUPPORTS1(nsAbDirProperty,nsIAbDirectory) diff --git a/mozilla/mailnews/addrbook/src/nsAbMDBDirProperty.cpp b/mozilla/mailnews/addrbook/src/nsAbMDBDirProperty.cpp index 36e7a5b362a..58ca7bebd4d 100644 --- a/mozilla/mailnews/addrbook/src/nsAbMDBDirProperty.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbMDBDirProperty.cpp @@ -56,10 +56,11 @@ nsAbMDBDirProperty::nsAbMDBDirProperty(void) { + m_dbRowID = 0; } nsAbMDBDirProperty::~nsAbMDBDirProperty(void) -{ +{ } @@ -109,7 +110,6 @@ NS_IMETHODIMP nsAbMDBDirProperty::AddMailListToDirectory(nsIAbDirectory *mailLis /* add addresses to the mailing list */ NS_IMETHODIMP nsAbMDBDirProperty::AddAddressToList(nsIAbCard *card) { - if (!m_AddressList) NS_NewISupportsArray(getter_AddRefs(m_AddressList)); PRUint32 i, count; diff --git a/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp b/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp index 96950fab49a..8a5365b1804 100644 --- a/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp +++ b/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp @@ -3041,14 +3041,25 @@ nsresult nsAddrDatabase::CreateABList(nsIMdbRow* listRow, nsIAbDirectory **resul nsCOMPtr dbmailList (do_QueryInterface(mailList, &rv)); - if (mailList) - { - GetListFromDB(mailList, listRow); - dbmailList->SetDbRowID(rowID); - mailList->SetIsMailList(PR_TRUE); + if (mailList) + { + // if we are using turbo, and we "exit" and restart with the same profile + // the current mailing list will still be in memory, so when we do + // GetResource() and QI, we'll get it again. + // in that scenario, the mailList that we pass in will already be + // be a mailing list, with a valid row and all the entries + // in that scenario, we can skip GetListFromDB(), which would have + // have added all the cards to the list again. + // see bug #134743 + mdb_id existingID; + dbmailList->GetDbRowID(&existingID); + if (existingID != rowID) { + GetListFromDB(mailList, listRow); + dbmailList->SetDbRowID(rowID); + mailList->SetIsMailList(PR_TRUE); + } dbm_dbDirectory->AddMailListToDirectory(mailList); - NS_IF_ADDREF(*result = mailList); } }