Only remove the transaction manager if we're handling the command.

This commit is contained in:
putterman%netscape.com 1999-07-24 21:48:45 +00:00
Родитель 0fbde9c198
Коммит d103d49bd4
3 изменённых файлов: 39 добавлений и 18 удалений

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

@ -415,24 +415,6 @@ nsMsgMessageDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources
nsISupportsArray/*<nsIRDFResource>*/* aArguments)
{
nsresult rv = NS_OK;
PRUint32 cnt;
rv = aSources->Count(&cnt);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsITransactionManager> transactionManager;
if (cnt > 1)
{
nsCOMPtr<nsISupports> supports;
supports = getter_AddRefs(aSources->ElementAt(0));
transactionManager = do_QueryInterface(supports, &rv);
if (NS_SUCCEEDED(rv) && transactionManager)
{
aSources->RemoveElementAt(0);
cnt--;
}
}
if((aCommand == kNC_MarkRead))
rv = DoMarkMessagesRead(aSources, PR_TRUE);
@ -621,6 +603,11 @@ nsMsgMessageDataSource::DoMarkMessagesRead(nsISupportsArray *messages, PRBool ma
PRUint32 count;
nsresult rv;
nsCOMPtr<nsITransactionManager> transactionManager;
rv = GetTransactionManager(messages, getter_AddRefs(transactionManager));
if(NS_FAILED(rv))
return rv;
rv = messages->Count(&count);
if(NS_FAILED(rv))
return rv;

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

@ -334,3 +334,35 @@ nsMsgRDFDataSource::unassertEnumFunc(nsISupports *aElement, void *aData)
return PR_TRUE;
}
nsresult
nsMsgRDFDataSource::GetTransactionManager(nsISupportsArray *aSources, nsITransactionManager **aTransactionManager)
{
if(!aTransactionManager)
return NS_ERROR_NULL_POINTER;
*aTransactionManager = nsnull;
nsresult rv = NS_OK;
nsCOMPtr<nsITransactionManager> transactionManager;
PRUint32 cnt;
rv = aSources->Count(&cnt);
if (NS_FAILED(rv)) return rv;
if (cnt > 0)
{
nsCOMPtr<nsISupports> supports;
supports = getter_AddRefs(aSources->ElementAt(0));
transactionManager = do_QueryInterface(supports, &rv);
if (NS_SUCCEEDED(rv) && transactionManager)
{
aSources->RemoveElementAt(0);
*aTransactionManager = transactionManager;
NS_IF_ADDREF(*aTransactionManager);
}
}
return NS_OK;
}

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

@ -25,6 +25,7 @@
#include "nsIRDFService.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsITransactionManager.h"
class nsMsgRDFDataSource : public nsIRDFDataSource,
public nsIShutdownListener
@ -165,6 +166,7 @@ class nsMsgRDFDataSource : public nsIRDFDataSource,
static PRBool unassertEnumFunc(nsISupports *aElement, void *aData);
nsresult NotifyObservers(nsIRDFResource *subject, nsIRDFResource *property,
nsIRDFNode *object, PRBool assert);
nsresult GetTransactionManager(nsISupportsArray *sources, nsITransactionManager **aTransactionManager);
private:
nsIRDFService *mRDFService;