1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-17 16:40:07 +02:00

Don't push vacuous undo items...

... Vacuous pushes should not happen yet, but may happen after the machinery
for pending track changes is added and used.

This will only detect the case of one new recording track being modified. It
will not detect it if that track is modified, but other tracks exist that are
not modified.
This commit is contained in:
Paul Licameli 2018-01-15 18:01:40 -05:00
parent 539e870302
commit 43776f5263

View File

@ -272,13 +272,6 @@ void UndoManager::PushState(const TrackList * l,
return; return;
} }
mayConsolidate = true;
i = current + 1;
while (i < stack.size()) {
RemoveStateAt(i);
}
auto tracksCopy = TrackList::Create(); auto tracksCopy = TrackList::Create();
for (auto t : *l) { for (auto t : *l) {
if ( t->GetId() == TrackId{} ) if ( t->GetId() == TrackId{} )
@ -287,6 +280,19 @@ void UndoManager::PushState(const TrackList * l,
tracksCopy->Add(t->Duplicate()); tracksCopy->Add(t->Duplicate());
} }
// Quit with no effects if the change looks vacuous
// (Don't examine track contents to decide vacuity)
if (current >= 0 &&
tags == stack[current]->state.tags && tracksCopy->empty())
return;
mayConsolidate = true;
i = current + 1;
while (i < stack.size()) {
RemoveStateAt(i);
}
// Assume tags was duplicted before any changes. // Assume tags was duplicted before any changes.
// Just save a NEW shared_ptr to it. // Just save a NEW shared_ptr to it.
stack.push_back( stack.push_back(