Porting 930586110 to 0.26 (problem with hidden undo)

This commit is contained in:
Matthias Koefferlein 2020-12-01 23:00:11 +01:00
parent e724dcdb45
commit d383f4a413
1 changed files with 15 additions and 6 deletions

View File

@ -146,15 +146,24 @@ Manager::last_transaction_id () const
void
Manager::cancel ()
{
// equivalent to commit and undo. But takes care that an empty commit is not followed by undo
// (which would undo the previous transaction!)
if (db::transactions_enabled ()) {
// commit and undo - revert changes done so far
commit ();
undo ();
tl_assert (m_opened);
tl_assert (! m_replay);
m_opened = false;
// delete all following transactions
erase_transactions (m_current, m_transactions.end ());
m_current = m_transactions.end ();
if (m_current->first.begin () != m_current->first.end ()) {
++m_current;
undo ();
} else {
// empty transactions .. just delete
erase_transactions (m_current, m_transactions.end ());
m_current = m_transactions.end ();
}
}
}