mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Bug2590: Compact Project should free up more space...
... but not always as much, as before the part of the fix for Bug2579, which is at 7edbad3cd131b115ead713482308508da8f172bc The last saved undo state and the current state must (both) be saved (if different).
This commit is contained in:
parent
ccffaca0fa
commit
003d1c23a3
@ -1257,10 +1257,11 @@ void ProjectFileManager::Compact()
|
||||
const auto least = std::min<size_t>(savedState, currentState);
|
||||
const auto greatest = std::max<size_t>(savedState, currentState);
|
||||
std::vector<const TrackList*> trackLists;
|
||||
undoManager.VisitStates(
|
||||
[&](auto& elem){
|
||||
trackLists.push_back(elem.state.tracks.get()); },
|
||||
least, 1 + greatest);
|
||||
auto fn = [&](auto& elem){
|
||||
trackLists.push_back(elem.state.tracks.get()); };
|
||||
undoManager.VisitStates(fn, least, 1 + least);
|
||||
if (least != greatest)
|
||||
undoManager.VisitStates(fn, greatest, 1 + greatest);
|
||||
|
||||
int64_t total = projectFileIO.GetTotalUsage();
|
||||
int64_t used = projectFileIO.GetCurrentUsage(trackLists);
|
||||
@ -1283,6 +1284,10 @@ void ProjectFileManager::Compact()
|
||||
// We can remove redo states, if they are after the saved state.
|
||||
undoManager.RemoveStates(1 + greatest, undoManager.GetNumStates());
|
||||
|
||||
// We can remove all states between the current and the last saved.
|
||||
if (least < greatest)
|
||||
undoManager.RemoveStates(least + 1, greatest);
|
||||
|
||||
// We can remove all states before the current and the last saved.
|
||||
undoManager.RemoveStates(0, least);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user