fix for 1.3 blocker bug #179856

crash when you undo a move (or copy).

this regression was caused by two checkins (#59694 and #166411)

the fix is to move the code that sets the src and dest keys on the
undo transaction back to where it was and to bullet proof
the undo transaction code so that if we don't have any src keys.

r=cavin, sr=bienvenu, a=asa


git-svn-id: svn://10.0.0.236/trunk@138061 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sspitzer%netscape.com
2003-02-21 01:20:44 +00:00
parent 886b125125
commit fb69ebe21f
3 changed files with 47 additions and 20 deletions

View File

@@ -189,6 +189,12 @@ nsImapMoveCopyMsgTxn::UndoTransaction(void)
nsMsgImapDeleteModel deleteModel;
rv = GetImapDeleteModel(srcFolder, &deleteModel);
// protect against a bogus undo txn without any source keys
// see bug #179856 for details
NS_ASSERTION(m_srcKeyArray.GetSize(), "no source keys");
if (!m_srcKeyArray.GetSize())
return NS_ERROR_UNEXPECTED;
if (NS_SUCCEEDED(rv) && deleteModel == nsMsgImapDeleteModels::IMAPDelete)
CheckForToggleDelete(srcFolder, m_srcKeyArray.GetAt(0), &deletedMsgs);
@@ -263,6 +269,13 @@ nsImapMoveCopyMsgTxn::RedoTransaction(void)
PRBool deletedMsgs = PR_FALSE; //default will be false unless imapDeleteModel;
nsMsgImapDeleteModel deleteModel;
rv = GetImapDeleteModel(srcFolder, &deleteModel);
// protect against a bogus undo txn without any source keys
// see bug #179856 for details
NS_ASSERTION(m_srcKeyArray.GetSize(), "no source keys");
if (!m_srcKeyArray.GetSize())
return NS_ERROR_UNEXPECTED;
if (NS_SUCCEEDED(rv) && deleteModel == nsMsgImapDeleteModels::IMAPDelete)
rv = CheckForToggleDelete(srcFolder, m_srcKeyArray.GetAt(0), &deletedMsgs);

View File

@@ -2539,11 +2539,11 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded)
NS_ENSURE_SUCCESS(rv,rv);
}
}
//Copy the header to the new database
if(copySucceeded && mCopyState->m_message)
{ // CopyMessages() goes here; CopyFileMessage() never gets in here because
//Copy the header to the new database
if(copySucceeded && mCopyState->m_message)
{ // CopyMessages() goes here; CopyFileMessage() never gets in here because
// the mCopyState->m_message will be always null for file message
nsCOMPtr<nsIMsgDBHdr> newHdr;
if(!mCopyState->m_parseMsgState)
@@ -2551,36 +2551,38 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded)
if(mDatabase)
{
rv = mDatabase->CopyHdrFromExistingHdr(mCopyState->m_curDstKey,
mCopyState->m_message, PR_TRUE,
getter_AddRefs(newHdr));
mCopyState->m_message, PR_TRUE,
getter_AddRefs(newHdr));
PRUint32 newHdrFlags;
// turn off offline flag - it's not valid for local mail folders.
if (newHdr)
newHdr->AndFlags(~MSG_FLAG_OFFLINE, &newHdrFlags);
PRBool isImap;
if (NS_SUCCEEDED(rv) && localUndoTxn)
localUndoTxn->GetSrcIsImap(&isImap);
if (NS_SUCCEEDED(rv) && localUndoTxn && (!isImap || !mCopyState->m_copyingMultipleMessages))
{
nsMsgKey aKey;
mCopyState->m_message->GetMessageKey(&aKey);
localUndoTxn->AddSrcKey(aKey);
localUndoTxn->AddDstKey(mCopyState->m_curDstKey);
}
}
else
mCopyState->m_undoMsgTxn = nsnull; //null out the transaction because we can't undo w/o the msg db
}
// if we plan on allowing undo, (if we have a mCopyState->m_parseMsgState or not)
// we need to save the source and dest keys on the undo txn.
// see bug #179856 for details
PRBool isImap;
if (NS_SUCCEEDED(rv) && localUndoTxn) {
localUndoTxn->GetSrcIsImap(&isImap);
if (!isImap || !mCopyState->m_copyingMultipleMessages)
{
nsMsgKey aKey;
mCopyState->m_message->GetMessageKey(&aKey);
localUndoTxn->AddSrcKey(aKey);
localUndoTxn->AddDstKey(mCopyState->m_curDstKey);
}
}
}
if (mCopyState->m_dummyEnvelopeNeeded)
{
mCopyState->m_fileStream->seek(PR_SEEK_END, 0);
*(mCopyState->m_fileStream) << MSG_LINEBREAK;
if (mCopyState->m_parseMsgState)
mCopyState->m_parseMsgState->ParseAFolderLine(CRLF, MSG_LINEBREAK_LEN);
mCopyState->m_parseMsgState->ParseAFolderLine(CRLF, MSG_LINEBREAK_LEN);
}
// CopyFileMessage() and CopyMessages() from servers other than mailbox

View File

@@ -244,6 +244,12 @@ nsLocalMoveCopyMsgTxn::UndoTransaction()
nsCOMPtr<nsIMsgDBHdr> oldHdr;
nsCOMPtr<nsIMsgDBHdr> newHdr;
// protect against a bogus undo txn without any source keys
// see bug #179856 for details
NS_ASSERTION(count, "no source keys");
if (!count)
return NS_ERROR_UNEXPECTED;
if (m_isMove)
{
if (m_srcIsImap4)
@@ -349,6 +355,12 @@ nsLocalMoveCopyMsgTxn::RedoTransaction()
{
if (m_srcIsImap4)
{
// protect against a bogus undo txn without any source keys
// see bug #179856 for details
NS_ASSERTION(m_srcKeyArray.GetSize(), "no source keys");
if (!m_srcKeyArray.GetSize())
return NS_ERROR_UNEXPECTED;
PRBool deleteFlag = PR_FALSE; //message is un-deleted- we are trying to redo
CheckForToggleDelete(srcFolder, m_srcKeyArray.GetAt(0), &deleteFlag); // there could have been a toggle
rv = UndoImapDeleteFlag(srcFolder, m_srcKeyArray, deleteFlag);