1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Bug2531: need progress indication when discarding undo history...

... You may see this also when abandoning lots of redo history, and not only
when doing compaction.

If in compaction you discard much undo and also much redo, you may see two
progresses.

It's debatable whether this might have been better implemented by reuse of
ProjectFileIO::DeleteBlocks instead, putting callbacks to a progress indicator
in the function InSet().  But I wanted to avoid more dependency onto
ProjectFileIO.

Doing real work in DeleteBlocks() is supposed to happen only if there is a bug
elsewhere that allowed orphans.  So, still no progress indicator there.
This commit is contained in:
Paul Licameli
2020-09-06 09:28:40 -04:00
parent dfd313f8fa
commit 8a86fe139f
4 changed files with 76 additions and 0 deletions

View File

@@ -147,6 +147,9 @@ public:
sampleFormat srcformat,
const wxChar **attrs) override;
BlockDeletionCallback SetBlockDeletionCallback(
BlockDeletionCallback callback ) override;
private:
friend SqliteSampleBlock;
@@ -159,6 +162,8 @@ private:
using AllBlocksMap =
std::map< SampleBlockID, std::weak_ptr< SqliteSampleBlock > >;
AllBlocksMap mAllBlocks;
BlockDeletionCallback mCallback;
};
SqliteSampleBlockFactory::SqliteSampleBlockFactory( AudacityProject &project )
@@ -272,6 +277,14 @@ SampleBlockPtr SqliteSampleBlockFactory::DoCreateFromXML(
return sb;
}
auto SqliteSampleBlockFactory::SetBlockDeletionCallback(
BlockDeletionCallback callback ) -> BlockDeletionCallback
{
auto result = mCallback;
mCallback = std::move( callback );
return result;
}
SqliteSampleBlock::SqliteSampleBlock(
const std::shared_ptr<SqliteSampleBlockFactory> &pFactory)
: mpFactory(pFactory)
@@ -287,6 +300,10 @@ SqliteSampleBlock::SqliteSampleBlock(
SqliteSampleBlock::~SqliteSampleBlock()
{
auto &callback = mpFactory->mCallback;
if (callback)
GuardedCall( [&]{ callback( *this ); } );
if (IsSilent()) {
// The block object was constructed but failed to Load() or Commit().
// Or it's a silent block with no row in the database.