Bug 1340972 - Part 11: Fix use of NS_ADDREF() and NS_IF_ADDREF() in mailnews/addrbook. r=aceman

This commit is contained in:
Jorg K 2017-09-13 19:48:38 +02:00
Родитель 2030517bc5
Коммит 2e9d9321fe
12 изменённых файлов: 45 добавлений и 74 удалений

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

@ -219,8 +219,7 @@ NS_IMETHODIMP nsAbDirProperty::GetAddressLists(nsIMutableArray * *aAddressLists)
NS_ENSURE_SUCCESS(rv, rv);
}
*aAddressLists = m_AddressList;
NS_ADDREF(*aAddressLists);
NS_ADDREF(*aAddressLists = m_AddressList);
return NS_OK;
}

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

@ -187,7 +187,7 @@ NS_IMETHODIMP nsAbLDAPCard::GetLDAPMessageInfo(
}
}
NS_ADDREF(*aLDAPAddMessageInfo = modArray);
modArray.forget(aLDAPAddMessageInfo);
return NS_OK;
}

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

@ -675,7 +675,7 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetReplicationFile(nsIFile **aResult)
rv = profileDir->AppendNative(fileName);
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*aResult = profileDir);
profileDir.forget(aResult);
return NS_OK;
}
@ -775,7 +775,7 @@ NS_IMETHODIMP nsAbLDAPDirectory::AddCard(nsIAbCard *aUpdatedCard,
EmptyCString(), EmptyCString());
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*aAddedCard = copyToCard);
copyToCard.forget(aAddedCard);
return NS_OK;
}

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

@ -321,7 +321,7 @@ NS_IMETHODIMP nsAbMDBDirectory::AddDirectory(const char *uriName, nsIAbDirectory
if (mSubDirectories.IndexOf(directory) == -1)
mSubDirectories.AppendObject(directory);
NS_IF_ADDREF(*childDir = directory);
directory.forget(childDir);
return rv;
}
@ -344,7 +344,7 @@ NS_IMETHODIMP nsAbMDBDirectory::GetDatabaseFile(nsIFile **aResult)
rv = dbFile->AppendNative(fileName);
NS_ENSURE_SUCCESS(rv, rv);
NS_ADDREF(*aResult = dbFile);
dbFile.forget(aResult);
return NS_OK;
}
@ -656,7 +656,7 @@ NS_IMETHODIMP nsAbMDBDirectory::AddMailList(nsIAbDirectory *list, nsIAbDirectory
NotifyItemAdded(newList);
}
NS_IF_ADDREF(*addedList = newList);
newList.forget(addedList);
return rv;
}

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

@ -266,7 +266,7 @@ NS_IMETHODIMP nsAbManager::GetDirectory(const nsACString &aURI,
{
rv = GetRootDirectory(getter_AddRefs(directory));
NS_ENSURE_SUCCESS(rv, rv);
NS_IF_ADDREF(*aResult = directory);
directory.forget(aResult);
return NS_OK;
}
@ -303,7 +303,7 @@ NS_IMETHODIMP nsAbManager::GetDirectory(const nsACString &aURI,
if (!isQuery)
mAbStore.Put(aURI, directory);
}
NS_IF_ADDREF(*aResult = directory);
directory.forget(aResult);
return NS_OK;
}
@ -1383,7 +1383,7 @@ NS_IMETHODIMP nsAbManager::EscapedVCardToAbCard(const char *aEscapedVCardStr, ns
NS_WARNING("Parse of vCard failed");
}
NS_IF_ADDREF(*aCard = cardFromVCard);
cardFromVCard.forget(aCard);
return NS_OK;
}

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

@ -447,7 +447,7 @@ NS_IMETHODIMP nsAbOutlookDirectory::AddMailList(nsIAbDirectory *aMailList, nsIAb
}
m_AddressList->AppendElement(newList, false);
NotifyItemAddition(newList);
NS_IF_ADDREF(*addedList = newList);
newList.forget(addedList);
return rv;
}
@ -1248,8 +1248,7 @@ nsresult nsAbOutlookDirectory::CreateCard(nsIAbCard *aData, nsIAbCard **aNewCard
retCode = ModifyCard(newCard) ;
NS_ENSURE_SUCCESS(retCode, retCode) ;
}
*aNewCard = newCard ;
NS_ADDREF(*aNewCard) ;
newCard.forget(aNewCard);
return retCode ;
}

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

@ -50,7 +50,7 @@ nsresult nsAbQueryStringToExpression::Convert (
nsCOMPtr<nsIAbBooleanExpression> e(do_QueryInterface(s, &rv));
NS_ENSURE_SUCCESS(rv, rv);
NS_IF_ADDREF(*expression = e);
e.forget(expression);
return rv;
}
@ -98,7 +98,7 @@ nsresult nsAbQueryStringToExpression::ParseExpression (
rv = ParseExpressions (index, e);
NS_ENSURE_SUCCESS(rv, rv);
NS_IF_ADDREF(*expression = e);
e.forget(expression);
}
// Case" "(*)"
else if (*indexBracket == ')')
@ -110,7 +110,7 @@ nsresult nsAbQueryStringToExpression::ParseExpression (
getter_AddRefs(conditionString));
NS_ENSURE_SUCCESS(rv, rv);
NS_IF_ADDREF(*expression = conditionString);
conditionString.forget(expression);
}
if (**index != ')')
@ -188,7 +188,7 @@ nsresult nsAbQueryStringToExpression::ParseCondition (
getter_AddRefs (c));
NS_ENSURE_SUCCESS(rv, rv);
NS_IF_ADDREF(*conditionString = c);
c.forget(conditionString);
return NS_OK;
}
@ -250,9 +250,8 @@ nsresult nsAbQueryStringToExpression::CreateBooleanExpression(
nsCOMPtr <nsIAbBooleanExpression> expr = do_CreateInstance(NS_BOOLEANEXPRESSION_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
NS_IF_ADDREF(*expression = expr);
rv = expr->SetOperation (op);
expr.forget(expression);
return rv;
}
@ -328,10 +327,7 @@ nsresult nsAbQueryStringToExpression::CreateBooleanConditionString (
rv = cs->SetValue (valueUCS2.get ());
NS_ENSURE_SUCCESS(rv, rv);
}
NS_IF_ADDREF(*conditionString = cs);
cs.forget(conditionString);
return NS_OK;
}

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

@ -1436,7 +1436,7 @@ NS_IMETHODIMP nsAbView::GetSelectedAddresses(nsIArray **_retval)
}
}
NS_IF_ADDREF(*_retval = addresses);
addresses.forget(_retval);
return NS_OK;
}

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

@ -62,16 +62,16 @@ NS_IMETHODIMP nsAddbookProtocolHandler::NewURI(const nsACString &aSpec,
nsIURI **_retval)
{
nsresult rv;
nsCOMPtr <nsIAddbookUrl> addbookUrl = do_CreateInstance(NS_ADDBOOKURL_CONTRACTID, &rv);
nsCOMPtr<nsIAddbookUrl> addbookUrl = do_CreateInstance(NS_ADDBOOKURL_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = addbookUrl->SetSpec(aSpec);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIURI> uri = do_QueryInterface(addbookUrl, &rv);
nsCOMPtr<nsIURI> uri = do_QueryInterface(addbookUrl, &rv);
NS_ENSURE_SUCCESS(rv,rv);
NS_ADDREF(*_retval = uri);
uri.forget(_retval);
return NS_OK;
}

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

@ -233,17 +233,16 @@ nsAddrDatabase::CleanupCache()
//----------------------------------------------------------------------
// FindInCache - this addrefs the db it finds.
//----------------------------------------------------------------------
nsAddrDatabase* nsAddrDatabase::FindInCache(nsIFile *dbName)
already_AddRefed<nsAddrDatabase> nsAddrDatabase::FindInCache(nsIFile *dbName)
{
nsTArray<nsAddrDatabase*>* dbCache = GetDBCache();
uint32_t length = dbCache->Length();
for (uint32_t i = 0; i < length; ++i)
{
nsAddrDatabase* pAddrDB = dbCache->ElementAt(i);
RefPtr<nsAddrDatabase> pAddrDB = dbCache->ElementAt(i);
if (pAddrDB->MatchDbName(dbName))
{
NS_ADDREF(pAddrDB);
return pAddrDB;
return pAddrDB.forget();
}
}
return nullptr;
@ -300,10 +299,10 @@ NS_IMETHODIMP nsAddrDatabase::Open
{
*pAddrDB = nullptr;
nsAddrDatabase *pAddressBookDB = FindInCache(aMabFile);
RefPtr<nsAddrDatabase> pAddressBookDB = FindInCache(aMabFile);
if (pAddressBookDB) {
*pAddrDB = pAddressBookDB;
pAddressBookDB.forget(pAddrDB);
return NS_OK;
}
@ -441,25 +440,19 @@ nsresult nsAddrDatabase::AlertAboutLockedMabFile(const char16_t *aFileName)
nsresult
nsAddrDatabase::OpenInternal(nsIFile *aMabFile, bool aCreate, nsIAddrDatabase** pAddrDB)
{
nsAddrDatabase *pAddressBookDB = new nsAddrDatabase();
if (!pAddressBookDB) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(pAddressBookDB);
RefPtr<nsAddrDatabase> pAddressBookDB = new nsAddrDatabase();
nsresult rv = pAddressBookDB->OpenMDB(aMabFile, aCreate);
if (NS_SUCCEEDED(rv))
{
pAddressBookDB->SetDbPath(aMabFile);
GetDBCache()->AppendElement(pAddressBookDB);
*pAddrDB = pAddressBookDB;
pAddressBookDB.forget(pAddrDB);
}
else
{
*pAddrDB = nullptr;
pAddressBookDB->ForceClosed();
NS_IF_RELEASE(pAddressBookDB);
pAddressBookDB = nullptr;
}
return rv;
@ -1283,14 +1276,12 @@ NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow
err = m_mdbPabTable->AddRow(m_mdbEnv, pCardRow);
}
nsCOMPtr<nsIAbCard> newCard;
CreateABCard(pCardRow, 0, getter_AddRefs(newCard));
NS_IF_ADDREF(*aPNewCard = newCard);
CreateABCard(pCardRow, 0, aPNewCard);
if (cardWasAdded) {
NotifyCardEntryChange(AB_NotifyInserted, newCard, aParent);
NotifyCardEntryChange(AB_NotifyInserted, *aPNewCard, aParent);
if (aRoot)
NotifyCardEntryChange(AB_NotifyInserted, newCard, aRoot);
NotifyCardEntryChange(AB_NotifyInserted, *aPNewCard, aRoot);
}
else if (!aInMailingList) {
nsresult rv;
@ -2307,7 +2298,6 @@ nsresult nsAddrDatabase::GetListFromDB(nsIAbDirectory *newList, nsIMdbRow* listR
if(NS_SUCCEEDED(err))
dbnewList->AddAddressToList(card);
}
// NS_IF_ADDREF(card);
}
return err;
@ -2586,12 +2576,8 @@ nsListAddressEnumerator::GetNext(nsISupports **aResult)
NS_IMETHODIMP nsAddrDatabase::EnumerateCards(nsIAbDirectory *directory, nsISimpleEnumerator **result)
{
nsAddrDBEnumerator* e = new nsAddrDBEnumerator(this);
NS_ADDREF(*result = new nsAddrDBEnumerator(this));
m_dbDirectory = do_GetWeakReference(directory);
if (!e)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(e);
*result = e;
return NS_OK;
}
@ -2646,14 +2632,10 @@ NS_IMETHODIMP nsAddrDatabase::EnumerateListAddresses(nsIAbDirectory *directory,
if(NS_SUCCEEDED(rv))
{
dbdirectory->GetDbRowID((uint32_t*)&rowID);
dbdirectory->GetDbRowID((uint32_t*)&rowID);
nsListAddressEnumerator* e = new nsListAddressEnumerator(this, rowID);
m_dbDirectory = do_GetWeakReference(directory);
if (!e)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(e);
*result = e;
NS_ADDREF(*result = new nsListAddressEnumerator(this, rowID));
m_dbDirectory = do_GetWeakReference(directory);
}
return rv;
}
@ -2680,7 +2662,7 @@ nsresult nsAddrDatabase::CreateCardFromDeletedCardsTable(nsIMdbRow* cardRow, mdb
InitCardFromRow(personCard, cardRow);
personCard->SetPropertyAsUint32(kRowIDProperty, rowID);
NS_IF_ADDREF(*result = personCard);
personCard.forget(result);
}
return rv;
@ -2718,7 +2700,7 @@ nsresult nsAddrDatabase::CreateCard(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbC
personCard->SetDirectoryId(id);
NS_IF_ADDREF(*result = personCard);
personCard.forget(result);
}
return rv;
@ -2776,7 +2758,7 @@ nsresult nsAddrDatabase::CreateABListCard(nsIMdbRow* listRow, nsIAbCard **result
personCard->SetDirectoryId(id);
}
NS_IF_ADDREF(*result = personCard);
personCard.forget(result);
}
if (listURI)
PR_smprintf_free(listURI);
@ -2835,7 +2817,7 @@ nsresult nsAddrDatabase::CreateABList(nsIMdbRow* listRow, nsIAbDirectory **resul
}
dbm_dbDirectory->AddMailListToDirectory(mailList);
NS_IF_ADDREF(*result = mailList);
mailList.forget(result);
}
}
@ -3090,7 +3072,7 @@ nsAddrDatabase::GetRowForCharColumn(const char16_t *unicodeStr,
if (NS_SUCCEEDED(rv) && equals)
{
NS_IF_ADDREF(*aFindRow = currentRow);
currentRow.forget(aFindRow);
if (aRowPos)
*aRowPos = rowPos;
return NS_OK;

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

@ -250,7 +250,7 @@ public:
nsIMdbTableRowCursor *GetTableRowCursor();
nsIMdbTable *GetPabTable() {return m_mdbPabTable;}
static nsAddrDatabase* FindInCache(nsIFile *dbName);
static already_AddRefed<nsAddrDatabase> FindInCache(nsIFile *dbName);
static void CleanupCache();

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

@ -149,7 +149,7 @@ NS_IMETHODIMP DirPrefObserver::Observe(nsISupports *aSubject, const char *aTopic
}
// A pointer to the pref observer
static DirPrefObserver *prefObserver = nullptr;
static RefPtr<DirPrefObserver> prefObserver;
static nsresult DIR_GetDirServers()
{
@ -168,11 +168,6 @@ static nsresult DIR_GetDirServers()
return rv;
prefObserver = new DirPrefObserver();
if (!prefObserver)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(prefObserver);
pbi->AddObserver(PREF_LDAP_SERVER_TREE_NAME, prefObserver, true);
}
}
@ -236,8 +231,8 @@ nsresult DIR_ShutDown() /* FEs should call this when the app is shutting down.
* We'll reset our callback the first time DIR_GetDirServers() is called
* after we've switched profiles.
*/
NS_IF_RELEASE(prefObserver);
prefObserver = nullptr;
return NS_OK;
}