From c4f2e82badc9d757e9f5cdd40ffe2303dd5719fb Mon Sep 17 00:00:00 2001 From: "bienvenu%nventure.com" Date: Wed, 30 Nov 2005 19:32:09 +0000 Subject: [PATCH] fix bug 317396, edited template disappears when saving or autosaving as draft, sr=mscott, part of patch by mkmelin+bugzilla@cc.hut.fi --- mailnews/compose/src/nsMsgCompose.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index a9612bf5b48b..1cc813445d86 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -3182,7 +3182,7 @@ nsMsgComposeSendListener::RemoveCurrentDraftMessage(nsIMsgCompose *compObj, PRBo PRUint32 folderFlags; msgFolder->GetFlags(&folderFlags); // only do this if it's a drafts or templates folder. - if (folderFlags & (MSG_FOLDER_FLAG_DRAFTS | MSG_FOLDER_FLAG_TEMPLATES)) + if (folderFlags & MSG_FOLDER_FLAG_DRAFTS) { // build the msg arrary nsCOMPtr messageArray; rv = NS_NewISupportsArray(getter_AddRefs(messageArray)); @@ -3195,7 +3195,7 @@ nsMsgComposeSendListener::RemoveCurrentDraftMessage(nsIMsgCompose *compObj, PRBo rv = messageArray->AppendElement(msgDBHdr); NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't append msg header to array."); if (NS_SUCCEEDED(rv)) - rv = msgFolder->DeleteMessages(messageArray, nsnull, PR_TRUE, PR_FALSE, nsnull, PR_FALSE /*allowUndo*/); + rv = msgFolder->DeleteMessages(messageArray, nsnull, PR_TRUE, PR_FALSE, nsnull, PR_FALSE /*allowUndo*/); NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveCurrentDraftMessage can't delete message."); } } @@ -3253,6 +3253,7 @@ nsMsgComposeSendListener::RemoveCurrentDraftMessage(nsIMsgCompose *compObj, PRBo // regardless whether or not the exiting msg can be deleted. if (calledByCopy) { + nsCOMPtr savedToFolder; nsCOMPtr msgSend; rv = compObj->GetMessageSend(getter_AddRefs(msgSend)); NS_ASSERTION(msgSend, "RemoveCurrentDraftMessage msgSend is null."); @@ -3263,25 +3264,21 @@ nsMsgComposeSendListener::RemoveCurrentDraftMessage(nsIMsgCompose *compObj, PRBo NS_ENSURE_SUCCESS(rv, rv); // Make sure we have a folder interface pointer - if (!msgFolder) - { - rv = GetMsgFolder(compObj, getter_AddRefs(msgFolder)); - NS_ENSURE_SUCCESS(rv, rv); - } + rv = GetMsgFolder(compObj, getter_AddRefs(savedToFolder)); // Reset draft (uid) url with the new uid. - if (msgFolder && newUid != nsMsgKey_None) + if (savedToFolder && newUid != nsMsgKey_None) { PRUint32 folderFlags; - msgFolder->GetFlags(&folderFlags); + savedToFolder->GetFlags(&folderFlags); if (folderFlags & MSG_FOLDER_FLAG_DRAFTS) { - rv = msgFolder->GenerateMessageURI(newUid, getter_Copies(newDraftIdURL)); - NS_ENSURE_SUCCESS(rv, rv); - compFields->SetDraftId(newDraftIdURL.get()); + rv = savedToFolder->GenerateMessageURI(newUid, getter_Copies(newDraftIdURL)); + NS_ENSURE_SUCCESS(rv, rv); + compFields->SetDraftId(newDraftIdURL.get()); + } } } - } return rv; }