Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 2499 - Macros: applying Macro to project always sets first track as focus
Macros: applying Macro to project always sets first track as focus
Status: CLOSED FIXED
Product: Audacity
Classification: Unclassified
Component: User Interface
3.0.0
All All
: P3 Repeatable
Assigned To: Default Assignee for New Bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2020-06-30 11:47 UTC by David Bailes
Modified: 2020-07-04 10:54 UTC (History)
7 users (show)

See Also:
Steps To Reproduce:
1. Create a Macro with the single command delete 2. Create a project with two audio tracks 3. Select some the audio in the second track, and ensure that the second track as the focus. 4. Apply the Macro. 5. The first track becomes the focus, whereas the expected behaviour is that the focus is unchanged.
Release Note:
First Git SHA:
Group: Accessibility
Workaround:
Closed: 2020-07-04 00:00:00
drbailes: Must‑Test‑All‑OS+
petersampsonaudacity: Test‑OK‑Win+
petersampsonaudacity: Test‑OK‑Mac+
stevethefiddle: Test‑OK‑Lin+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Bailes 2020-06-30 11:47:01 UTC
Applying a macro to the project sets the first track as the focus - it was spotted by someone on the forums.
After applying commands such as delete, one would expect the focus to be unchanged.
After applying effects, one would currently expect to the focus to be the first selected track.
This is inconvenient for keyboard users who then probably have to move back to the track which they were working on.
This is a regression on 2.3.3.

The cause of the problem is in:
bool MacroCommands::ApplyMacro(
   const MacroCommandsCatalog &catalog, const wxString & filename)

Specifically, the lines:
auto cleanup2 = finally([&] {
         if (!res) {
            if (proj) {
               // Macro failed or was cancelled; revert to the previous state
               ProjectHistory::Get(*proj).RollbackState();
            }
         }
         });

The boolean res is always false,  RollbackState() is called, which eventually causes TrackPanel::OnUndoReset() to be called, which sets the first track to be the focus.
Comment 1 Steve Daulton 2020-06-30 11:56:16 UTC
I had assumed this behaviour was intended.

On Linux with Audacity 2.3.3, track focus is lost altogether after running a Macro, so the current behaviour is an improvement, though I think returning focus to the first audio track unexpected.

I would have expected focus to return to wherever focus was prior to running the Macro.
Comment 2 Peter Sampson 2020-06-30 12:05:17 UTC
(In reply to Steve Daulton from comment #1)
>I would have expected focus to return to wherever focus was prior to 
>running the Macro.

Not necessarily as there are several Macro commands for changing the focused track.

Accordingly, I think:

a) If focussed track is changed in the Macro it should be left where it was last changed to.

b) If focussed track is not changed in the Macro it should be left where it was before the Macro was run.
Comment 3 David Bailes 2020-07-04 04:54:16 UTC
Fixed with commits:
https://github.com/audacity/audacity/commit/d9663035586a5cf60f4b7e5701c1e98356759691
https://github.com/audacity/audacity/commit/51b3b0f19a7f7699f029f33b43a9c7e62c1179b4
(Alas, I forgot to squash before committing.)

Notes:
1. On the basis of comments made by Steve, this bug may have accidentally fixed a bug on Linux where the track panel does not regain focus after executing a macro. If this is the case, then this fix will reintroduce that bug, which should be logged as a separate bug.

2. This fix also fixes a bug when a command in a macro is cancelled. Prior to the fix, if a macro contained a number of commands, then if a command after the first command was cancelled, the state of the project was not rolled back to the state before the macro was applied. This is now fixed.

3. There remains a bug concerning cancelling a command in a macro which is unaffected by this fix. After cancelling the command, an entry for the macro remains in the undo history. This is a separate bug.
Comment 4 David Bailes 2020-07-04 08:02:59 UTC
(In reply to David Bailes from comment #3)
> Fixed with commits:
> https://github.com/audacity/audacity/commit/
> d9663035586a5cf60f4b7e5701c1e98356759691
> https://github.com/audacity/audacity/commit/
> 51b3b0f19a7f7699f029f33b43a9c7e62c1179b4
> (Alas, I forgot to squash before committing.)

Minor improvement to the code with this commit:
https://github.com/audacity/audacity/commit/a415c3fe3898d917a8d55366f8e6ea6a36ec8e53

> 
> Notes:
> 1. On the basis of comments made by Steve, this bug may have accidentally
> fixed a bug on Linux where the track panel does not regain focus after
> executing a macro. If this is the case, then this fix will reintroduce that
> bug, which should be logged as a separate bug.
> 
> 2. This fix also fixes a bug when a command in a macro is cancelled. Prior
> to the fix, if a macro contained a number of commands, then if a command
> after the first command was cancelled, the state of the project was not
> rolled back to the state before the macro was applied. This is now fixed.
> 
> 3. There remains a bug concerning cancelling a command in a macro which is
> unaffected by this fix. After cancelling the command, an entry for the macro
> remains in the undo history. This is a separate bug.
Comment 5 Peter Sampson 2020-07-04 09:19:56 UTC
Testing on W10 with Audacity 3.0.0 51b3b0f

This looks to be fixed, after applying the Macro focus remains in the track the Macro was applied to.
Comment 6 Peter Sampson 2020-07-04 09:21:02 UTC
Testing on macOS 10.15.5 Catalina with Audacity 3.0.0 51b3b0f

This looks to be fixed, after applying the Macro focus remains in the track the Macro was applied to.
Comment 7 Peter Sampson 2020-07-04 09:28:58 UTC
(In reply to David Bailes from comment #3)
David "other bugs" should be logged in their own Bugzilla entries.

If they are already logged then a reference to the bug numbers here would be useful where you are discussing them.
Comment 8 Steve Daulton 2020-07-04 10:23:46 UTC
(In reply to David Bailes from comment #3)
Looks good on Linux.
Focus is returned to the expected track. 
If the Macro includes commands to move focus to a different track, Audacity sets focus to the correct track.