mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-31 08:58:43 +01:00
Dont delete sample blocks prematurely (#648)
* Revert "AUP3: Don't delete sample blocks prematurely" This reverts commitc1884349d5. * "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 ofc188434also 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:
@@ -24,7 +24,7 @@ struct sqlite3_stmt;
|
||||
struct sqlite3_value;
|
||||
|
||||
class AudacityProject;
|
||||
class AutoCommitTransaction;
|
||||
class TransactionScope;
|
||||
class DBConnection;
|
||||
class ProjectSerializer;
|
||||
class SqliteSampleBlock;
|
||||
@@ -240,14 +240,16 @@ 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
|
||||
class TransactionScope
|
||||
{
|
||||
public:
|
||||
AutoCommitTransaction(ProjectFileIO &projectFileIO, const char *name);
|
||||
~AutoCommitTransaction();
|
||||
TransactionScope(ProjectFileIO &projectFileIO, const char *name);
|
||||
~TransactionScope();
|
||||
|
||||
bool Rollback();
|
||||
bool Commit();
|
||||
|
||||
private:
|
||||
ProjectFileIO &mIO;
|
||||
|
||||
Reference in New Issue
Block a user