mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-15 16:17:41 +02:00
Fix assertions on close, again, better
This commit is contained in:
parent
e3d6c37163
commit
7fcd90e351
@ -174,6 +174,9 @@ void UndoManager::RemoveStateAt(int n)
|
||||
/*! This estimate procedure should in fact be exact */
|
||||
size_t UndoManager::EstimateRemovedBlocks(size_t begin, size_t end)
|
||||
{
|
||||
if (begin == end)
|
||||
return 0;
|
||||
|
||||
// Collect ids that survive
|
||||
SampleBlockIDSet wontDelete;
|
||||
auto f = [&](const auto &p){
|
||||
@ -182,13 +185,13 @@ size_t UndoManager::EstimateRemovedBlocks(size_t begin, size_t end)
|
||||
auto first = stack.begin(), last = stack.end();
|
||||
std::for_each( first, first + begin, f );
|
||||
std::for_each( first + end, last, f );
|
||||
if (saved >= 0)
|
||||
std::for_each( first + saved, first + saved + 1, f );
|
||||
InspectBlocks(TrackList::Get(mProject), {}, &wontDelete);
|
||||
|
||||
// Collect ids that won't survive (and are not negative pseudo ids)
|
||||
SampleBlockIDSet seen, mayDelete;
|
||||
for( auto ii = begin; ii < end; ++ii) {
|
||||
if (ii == saved)
|
||||
continue;
|
||||
auto &p = *(first + ii);
|
||||
std::for_each( first + begin, first + end, [&](const auto &p){
|
||||
auto &tracks = *p->state.tracks;
|
||||
InspectBlocks(tracks, [&]( const SampleBlock &block ){
|
||||
auto id = block.GetBlockID();
|
||||
@ -196,7 +199,7 @@ size_t UndoManager::EstimateRemovedBlocks(size_t begin, size_t end)
|
||||
mayDelete.insert( id );
|
||||
},
|
||||
&seen);
|
||||
}
|
||||
} );
|
||||
return mayDelete.size();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user