From 5d1ffa22cf1adfb8cf37030b8f79df8dbba1f1d3 Mon Sep 17 00:00:00 2001 From: "putterman%netscape.com" Date: Thu, 29 Apr 1999 01:37:40 +0000 Subject: [PATCH] Fixed ref counting problems related to deleting a message. Reviewed by bienvenu and approved by chofmann --- .../base/util/nsLocalFolderSummarySpec.cpp | 5 +++++ mailnews/base/util/nsLocalFolderSummarySpec.h | 1 + mailnews/base/util/nsMsgUtils.cpp | 20 +++++++++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/mailnews/base/util/nsLocalFolderSummarySpec.cpp b/mailnews/base/util/nsLocalFolderSummarySpec.cpp index 8c9656da873..0399076d666 100644 --- a/mailnews/base/util/nsLocalFolderSummarySpec.cpp +++ b/mailnews/base/util/nsLocalFolderSummarySpec.cpp @@ -20,6 +20,11 @@ #include "plstr.h" #include "nsString.h" +nsLocalFolderSummarySpec::~nsLocalFolderSummarySpec() +{ + +} + nsLocalFolderSummarySpec::nsLocalFolderSummarySpec() { } diff --git a/mailnews/base/util/nsLocalFolderSummarySpec.h b/mailnews/base/util/nsLocalFolderSummarySpec.h index d1f64334379..2e68193f79b 100644 --- a/mailnews/base/util/nsLocalFolderSummarySpec.h +++ b/mailnews/base/util/nsLocalFolderSummarySpec.h @@ -30,6 +30,7 @@ class nsLocalFolderSummarySpec : public nsFileSpec { public: + virtual ~nsLocalFolderSummarySpec(); nsLocalFolderSummarySpec(); nsLocalFolderSummarySpec(const char *folderPath, PRBool create = PR_FALSE); nsLocalFolderSummarySpec(const nsFileSpec& inFolderPath); diff --git a/mailnews/base/util/nsMsgUtils.cpp b/mailnews/base/util/nsMsgUtils.cpp index 917b141c22e..635dee69ed4 100644 --- a/mailnews/base/util/nsMsgUtils.cpp +++ b/mailnews/base/util/nsMsgUtils.cpp @@ -20,6 +20,7 @@ #include "nsString.h" #include "nsFileSpec.h" #include "nsIServiceManager.h" +#include "nsCOMPtr.h" nsresult GetMessageServiceProgIDForURI(const char *uri, nsString &progID) { @@ -110,20 +111,27 @@ NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::Next(void) NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::CurrentItem(nsISupports **aItem) { - nsISupports *currentItem = nsnull; - nsIMsgDBHdr *msgDBHdr = nsnull; - nsIMessage *message = nsnull; + nsCOMPtr currentItem; + nsCOMPtr msgDBHdr; + nsCOMPtr message; nsresult rv; - rv = mSrcEnumerator->CurrentItem(¤tItem); + rv = mSrcEnumerator->CurrentItem(getter_AddRefs(currentItem)); if(NS_SUCCEEDED(rv)) - rv = currentItem->QueryInterface(nsIMsgDBHdr::GetIID(), (void**)&msgDBHdr); + { + msgDBHdr = do_QueryInterface(currentItem, &rv); + } if(NS_SUCCEEDED(rv)) - rv = mFolder->CreateMessageFromMsgDBHdr(msgDBHdr, &message); + { + rv = mFolder->CreateMessageFromMsgDBHdr(msgDBHdr, getter_AddRefs(message)); + } if(NS_SUCCEEDED(rv)) + { *aItem = message; + NS_ADDREF(*aItem); + } return rv; }