1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-05 16:43:52 +01:00

Bug 2499 - Macros: applying macro to project focus problem

Problem:
Applying macro to project always sets first track as focus.

The problem was introduced by commit 06cddda, which accidentally declared cleanup2 in the wrong scope.
This meant that ProjectHistory::RollBackState() was always called, which eventually causes TrackPanel::OnUndoReset() to be called, which sets the first track to be the focus.

Fix:
Declare cleanup2 in the correct scope.
This commit is contained in:
David Bailes
2020-07-04 09:06:53 +01:00
parent d966303558
commit 51b3b0f19a

View File

@@ -969,6 +969,8 @@ bool MacroCommands::ApplyMacro(
} }
// Upon exit of the top level apply, roll back the state if an error occurs. // Upon exit of the top level apply, roll back the state if an error occurs.
// This code relies on cleanup2 being defined after cleanup1, so that its
// destructor is run before cleanup1's destructor.
auto cleanup2 = finally([&] { auto cleanup2 = finally([&] {
if (MacroReentryCount == 1 && !res && proj) { if (MacroReentryCount == 1 && !res && proj) {
// Macro failed or was cancelled; revert to the previous state // Macro failed or was cancelled; revert to the previous state