1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-04-03 21:07:36 +02:00

Dont delete sample blocks prematurely (#648)

* Revert "AUP3: Don't delete sample blocks prematurely"

This reverts commit c1884349d5.

* "Don't delete sample blocks prematurely" fixed otherwise...

... and very simply.

Problem was that, only for an interactive effect (like Bass and Treble), the
save point was created, rolled back, created again, then committed.

But (unlike with the non-savepoint commands, even if savepoint is outermost),
rolling back a savepoint really just rewinds it without removing it -- therefore
the second savepoint was inner, but the first (outer) was never committed, so
some changes failed to persist.

Solution:  add a commit after rollback of savepoint to implement destructor
of AutoCommitTransaction.

The reversion of c188434 also leaves AutoCommitTransaction as a better RAII
style operation.  Rollback changes by default -- keep changes only if
success is explicitly indicated.

* Rename AutoCommitTransaction as TransactionScope...

... More appropriately, since it's now the rollback that is automatic but
the commit that must be explicit
This commit is contained in:
Paul Licameli
2020-08-28 16:38:38 -04:00
committed by GitHub
parent 1bb34e703e
commit c17b804750
4 changed files with 23 additions and 12 deletions

View File

@@ -740,7 +740,7 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
projectFileIO.SetBypass();
{
AutoCommitTransaction trans(projectFileIO, "Shutdown");
TransactionScope trans(projectFileIO, "Shutdown");
// This can reduce reference counts of sample blocks in the project's
// tracks.
@@ -748,6 +748,8 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
// Delete all the tracks to free up memory
tracks.Clear();
trans.Commit();
}
// We're all done with the project file, so close it now