From 51b3b0f19a7f7699f029f33b43a9c7e62c1179b4 Mon Sep 17 00:00:00 2001 From: David Bailes Date: Sat, 4 Jul 2020 09:06:53 +0100 Subject: [PATCH] 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. --- src/BatchCommands.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index 108c75d68..912004bb2 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -969,6 +969,8 @@ bool MacroCommands::ApplyMacro( } // 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([&] { if (MacroReentryCount == 1 && !res && proj) { // Macro failed or was cancelled; revert to the previous state