From c1884349d595a2fb889c90f209ea4af3d1c70e1d Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Sat, 25 Jul 2020 20:03:23 -0500 Subject: [PATCH] AUP3: Don't delete sample blocks prematurely The wrong sample blocks would be deleted at close in step 6: 1) New Project 2) Save and name 3) Import one stereo MP3 (about 6 minutes) 4) Save, close and re-open 5) Apply Bass and Treble to the track using real-time preview 6) Save, close and re-open 7) Message Failed to retrieve sample block --- src/ProjectFileIO.cpp | 6 +++--- src/ProjectFileIO.h | 4 +--- src/ProjectManager.cpp | 2 -- src/effects/Effect.cpp | 3 --- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index c00763f45..98e215663 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -2162,7 +2162,7 @@ AutoCommitTransaction::~AutoCommitTransaction() { if (mInTrans) { - if (!mIO.TransactionRollback(mName)) + if (!mIO.TransactionCommit(mName)) { // Do not throw from a destructor! // This has to be a no-fail cleanup that does the best that it can. @@ -2170,13 +2170,13 @@ AutoCommitTransaction::~AutoCommitTransaction() } } -bool AutoCommitTransaction::Commit() +bool AutoCommitTransaction::Rollback() { if ( !mInTrans ) // Misuse of this class THROW_INCONSISTENCY_EXCEPTION; - mInTrans = !mIO.TransactionCommit(mName); + mInTrans = !mIO.TransactionRollback(mName); return mInTrans; } diff --git a/src/ProjectFileIO.h b/src/ProjectFileIO.h index 704b92aa0..084f90d3a 100644 --- a/src/ProjectFileIO.h +++ b/src/ProjectFileIO.h @@ -221,8 +221,6 @@ private: }; // Make a savepoint (a transaction, possibly nested) with the given name; -// roll it back at destruction time, unless an explicit Commit() happened first. -// Commit() must not be called again after one successful call. // An exception is thrown from the constructor if the transaction cannot open. class AutoCommitTransaction { @@ -230,7 +228,7 @@ public: AutoCommitTransaction(ProjectFileIO &projectFileIO, const char *name); ~AutoCommitTransaction(); - bool Commit(); + bool Rollback(); private: ProjectFileIO &mIO; diff --git a/src/ProjectManager.cpp b/src/ProjectManager.cpp index 1960b6f6a..ab1eac0c5 100644 --- a/src/ProjectManager.cpp +++ b/src/ProjectManager.cpp @@ -748,8 +748,6 @@ 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 diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index ded4443e4..bb6928182 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1251,9 +1251,6 @@ bool Effect::DoEffect(double projectRate, // LastUsedDuration may have been modified by Preview. SetDuration(oldDuration); } - else - trans.Commit(); - End(); ReplaceProcessedTracks( false ); } );