diff --git a/editor/txmgr/src/nsTransactionManager.cpp b/editor/txmgr/src/nsTransactionManager.cpp index 463d9252770..6e8e7e537a6 100644 --- a/editor/txmgr/src/nsTransactionManager.cpp +++ b/editor/txmgr/src/nsTransactionManager.cpp @@ -482,26 +482,22 @@ nsTransactionManager::SetMaxTransactionCount(PRInt32 aMaxCount) LOCK_TX_MANAGER(this); - result = mDoStack.GetSize(&total); - if (NS_SUCCEEDED(result) && total) { + // It is illegal to call SetMaxTransactionCount() while the transaction + // manager is executing a transaction's DoTransaction() method because + // the undo and redo stacks might get pruned! If this happens, the + // SetMaxTransactionCount() request is ignored, and we return + // NS_ERROR_FAILURE. - // It is illegal to call SetMaxTransactionCount() while the transaction - // manager is executing a transaction's DoTransaction() method because - // the undo and redo stacks might get pruned! If this happens, the - // SetMaxTransactionCount() request is ignored, and we return - // NS_ERROR_FAILURE. + result = mDoStack.Peek(&tx); - result = mDoStack.Peek(&tx); + if (NS_FAILED(result)) { + UNLOCK_TX_MANAGER(this); + return result; + } - if (NS_FAILED(result)) { - UNLOCK_TX_MANAGER(this); - return result; - } - - if (tx) { - UNLOCK_TX_MANAGER(this); - return NS_ERROR_FAILURE; - } + if (tx) { + UNLOCK_TX_MANAGER(this); + return NS_ERROR_FAILURE; } // If aMaxCount is less than zero, the user wants unlimited diff --git a/editor/txmgr/src/nsTransactionStack.cpp b/editor/txmgr/src/nsTransactionStack.cpp index 40e86e3a1bb..f4cc633b209 100644 --- a/editor/txmgr/src/nsTransactionStack.cpp +++ b/editor/txmgr/src/nsTransactionStack.cpp @@ -101,14 +101,12 @@ nsTransactionStack::Peek(nsTransactionItem **aTransaction) if (!aTransaction) return NS_ERROR_NULL_POINTER; - if (!mQue.GetSize()) - return NS_ERROR_NULL_POINTER; + if (!mQue.GetSize()) { + *aTransaction = 0; + return NS_OK; + } - /* nsDeque's End() method returns an iterator that is - * passed the last entry of the deque. We need to decrement - * to get to the last entry. - */ - *aTransaction = (nsTransactionItem *)(--mQue.End()); + *aTransaction = (nsTransactionItem *)(mQue.End().GetCurrent()); return NS_OK; }