1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-31 17:08:45 +01:00

Preliminaries for grouped block deletion (#628)

* Change usage of AutoCommitTransaction::Rollback...

... It is the more useful pattern (as in many finally blocks) for the failure
path in the destructor (which rolls back) to be the default, but an explicit
call must inform it of success.

This corrects the early return paths in Effect::DoEffect().

Throw inconsistency exception if Commit() is called again after having been
called once, successfully

Also remove a friend declaration

* UndoManager's interface uses consistent 0-based indexing of states...

... Returned by GetCurrentState() and used by SetStateTo(),
GetLongDescription(), GetShortDescription()

* SampleBlock::GetBlockID is const

* Generalized function to visit sample blocks used in a TrackList...

... Eliminating some duplication; put it in WaveTrack, not Track, to avoid
a dependency cycle.

* Eliminate more repetition with BlockSpaceUsageAccumulator

* Function to delete all blocks of/not-of a given set in one command
This commit is contained in:
Paul Licameli
2020-07-23 12:17:29 -04:00
committed by GitHub
parent d677bead7a
commit a8fd6c6ce8
13 changed files with 120 additions and 115 deletions

View File

@@ -12,7 +12,7 @@ Paul Licameli split from AudacityProject.h
#define __AUDACITY_PROJECT_FILE_IO__
#include <memory>
#include <set>
#include <unordered_set>
#include "ClientData.h" // to inherit
#include "Prefs.h" // to inherit
@@ -166,12 +166,15 @@ private:
bool WriteDoc(const char *table, const ProjectSerializer &autosave, const char *schema = "main");
// Application defined function to verify blockid exists is in set of blockids
using BlockIDs = std::set<SampleBlockID>;
using BlockIDs = std::unordered_set<SampleBlockID>;
static void InSet(sqlite3_context *context, int argc, sqlite3_value **argv);
// Checks for orphan blocks. This will go away at a future date
bool CheckForOrphans(BlockIDs &blockids);
public:
// In one SQL command, delete sample blocks with ids in the given set, or
// (when complement is true), with ids not in the given set.
bool DeleteBlocks(const BlockIDs &blockids, bool complement);
private:
// Return a database connection if successful, which caller must close
Connection CopyTo(const FilePath &destpath,
const TranslatableString &msg,
@@ -213,10 +216,12 @@ private:
TranslatableString mLastError;
TranslatableString mLibraryError;
friend AutoCommitTransaction;
};
// 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
{
public:
@@ -224,7 +229,6 @@ public:
~AutoCommitTransaction();
bool Commit();
bool Rollback();
private:
ProjectFileIO &mIO;