1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-29 22:58:39 +02:00

Correct space usage calculation for the clipboard in History dialog

This commit is contained in:
Paul Licameli 2020-07-21 01:37:33 -04:00
parent f7400d86e9
commit 73c6225906

View File

@ -94,7 +94,7 @@ UndoManager::~UndoManager()
namespace { namespace {
SpaceArray::value_type SpaceArray::value_type
CalculateUsage(const TrackList &tracks, Set *seen) CalculateUsage(const TrackList &tracks, Set &seen)
{ {
SpaceArray::value_type result = 0; SpaceArray::value_type result = 0;
@ -110,17 +110,15 @@ namespace {
{ {
const auto &sb = block.sb; const auto &sb = block.sb;
// Accumulate space used by the file if the file was not // Accumulate space used by the block if the block was not
// yet seen // yet seen
if ( !seen || (seen->count( sb->GetBlockID() ) == 0 ) ) if ( seen.count( sb->GetBlockID() ) == 0 )
{ {
unsigned long long usage{ sb->GetSpaceUsage() }; unsigned long long usage{ sb->GetSpaceUsage() };
result += usage; result += usage;
}
// Add file to current set seen.insert( sb->GetBlockID() );
if (seen) }
seen->insert( sb->GetBlockID() );
} }
} }
} }
@ -154,11 +152,14 @@ void UndoManager::CalculateSpaceUsage()
{ {
// Scan all tracks at current level // Scan all tracks at current level
auto &tracks = *stack[nn]->state.tracks; auto &tracks = *stack[nn]->state.tracks;
space[nn] = CalculateUsage(tracks, &seen); space[nn] = CalculateUsage(tracks, seen);
} }
// Count the usage of the clipboard separately, using another set. Do not
// multiple-count any block occurring multiple times within the clipboard.
Set seen2;
mClipboardSpaceUsage = CalculateUsage( mClipboardSpaceUsage = CalculateUsage(
Clipboard::Get().GetTracks(), nullptr); Clipboard::Get().GetTracks(), seen2);
//TIMER_STOP( space_calc ); //TIMER_STOP( space_calc );
} }