diff --git a/src/App/Transactions.cpp b/src/App/Transactions.cpp index 4ab3334b56..2f31fa4c08 100644 --- a/src/App/Transactions.cpp +++ b/src/App/Transactions.cpp @@ -194,9 +194,12 @@ void Transaction::addObjectNew(TransactionalObject *Obj) auto pos = index.find(Obj); if (pos != index.end()) { if (pos->second->status == TransactionObject::Del) { - delete pos->second; - delete pos->first; + // first remove the item from the container before deleting it + auto second = pos->second; + auto first = pos->first; index.erase(pos); + delete second; + delete first; } else { pos->second->status = TransactionObject::New;