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

Audacity Bugzilla



Bug 624 - Keyboard Preferences: No check on importing XML file for duplicated bindings
Keyboard Preferences: No check on importing XML file for duplicated bindings
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: User Interface
2.0.4
Per OS All
: P3 RepeatableAll
Assigned To: Default Assignee for New Bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-16 19:22 UTC by Gale Andrews
Modified: 2021-02-01 17:08 UTC (History)
7 users (show)

See Also:
Steps To Reproduce:
1. Open Keyboard Preferences, press "Defaults", then Export these to an XML file. 2. Open the XML file in a text editor and add a binding Ctrl+O to command name="CheckDeps" near the top. Save the file. 3. Import the XML file. 4. Observe: Audacity loads the added shortcut for CheckDeps, which conflicts with the existing binding for File > Open.
Release Note:
Group Keyboard Preferences *When importing keyboard shortcuts from an XML file it is possible to have shortcuts that duplicate existing shortcuts that you have in Audacity (audacity shortcuts or custom shortcuts). Audacity does not check for this and the imported duplicate conflicts with the pre-existing shortcut
First Git SHA:
Group: ---
Workaround:
Check your import XML file against you existing shortcuts in Keyboard preferences and avoid duplicates.
Closed: 2021-02-01 00:00:00
petersampsonaudacity: Test‑OK‑Win+
petersampsonaudacity: Test‑OK‑Mac+


Attachments
error message for duplicates (65.76 KB, image/png)
2021-02-01 16:55 UTC, Peter Sampson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gale Andrews 2013-03-16 19:22:27 UTC

    
Comment 1 Peter Sampson 2019-06-12 08:01:41 UTC
Upgraded to P3 and added a Release Note and Workaround
Comment 2 David Bailes 2019-10-19 09:36:49 UTC
The fix for bug 1762 introduced a different behaviour when keyboard shortcuts are imported: these become your shortcuts, regardless of any customizations present before the import. I think this behaviour is straightforward, and what the user expects.

With this new behaviour, the steps to reproduce no longer produce a conflict, and so I think this bug can be closed.
Comment 3 David Bailes 2019-10-19 09:57:15 UTC
(In reply to David Bailes from comment #2)
> The fix for bug 1762 introduced a different behaviour when keyboard
> shortcuts are imported: these become your shortcuts, regardless of any
> customizations present before the import. I think this behaviour is
> straightforward, and what the user expects.
> 
> With this new behaviour, the steps to reproduce no longer produce a
> conflict, and so I think this bug can be closed.

Please ignore the above comment - I hadn't read the steps to reproduce properly.
Comment 4 Peter Sampson 2019-10-21 07:37:46 UTC
from the email discussion thread on the quality list:

I think I'm agreeing with David too  in that I think Option 1 is the way to go
>1. Open a message box which tells the user why the file is invalid, the 
>shortcuts are not imported, and the user has to go back and edit the xml file 
>to make it valid. 

a) It is an erroneous xml file of shortcuts
b) we should not second-guess which of the duplicated shortcuts should take
precedence and be accepted
c) rather the import of the xml shortcuts should be blocked and an error message
should be shown telling the user what the duplicates are
Comment 5 Steve Daulton 2019-10-25 13:12:39 UTC
Additional / alternative steps to reproduce this bug (from Pavel Shostak):


1. Go to Preferences->Keyboard and set Default Standard shortcuts.
2. Export shortcuts.
3. Open the resulting xlm-file in a text editor and remove line 3 (for Open)
4. Change the shortcut in a new line 3 (for Close, ex-line 4) to "Ctrl+O".
5. Save the file.
6. Import that xml-file in Preferences->Keyboard. Now, both Open and Close have the same shortcut.

The importance of this check is that the XML file is valid (does not contain duplicates), but will currently create a duplicate keyboard shortcut in Audacity.

On Importing keyboard shortcuts, Audacity must not only check that the imported shortcuts are unique (so that the XML file is "valid"), but must also check if they conflict with existing shortcuts. The dominant opinion in the QA discussion is that imported shortcuts should override existing shortcuts.
Comment 6 Steve Daulton 2019-10-25 13:20:00 UTC
(In reply to Steve Daulton from comment #5)
There are a few cases where duplicate shortcuts are "legal" (allowed).
These cases may be found by looking through the Full set of default key bindings.
Comment 7 Leland Lucius 2021-01-28 20:51:40 UTC
I believe this was fixed by Binary Wisdom in commit:

https://github.com/audacity/audacity/commit/9bce51a60ec23d09de5bbf9010bd3b98892dedc9

The fix follows the agreed behavior (see emails from around October 25) . For the sake of convenience see the agreed behavior below:

_"- first, check the xml-file. If it contains illegal shortcut duplicates, refuse importing. Shortcut duplicates are LEGAL if default settings also have those operations with the matching shortcuts. A refusal to import shortcuts must happen with the message that warns the user of a failure and explains the reason.

if the xml-file looks ok, import the shortcuts. As discussed before, because different versions of Audacity might have different sets of operations with shortcuts, it is still possible to end up with illegal shortcut duplicates for a perfectly correct xml-file. This situation must be monitored. In case of any conflicts, the shortcut from the xml-file is used, and the pre-existing shortcut is wiped clean.
When telling the user the commands which have had their shortcut removed, I think it would be useful to tell the user the name of the command, the shortcut, and and name of the command which still has that shortcut."_

I didn't find a clean way to intercept the imported content before it makes its way to the shortcut preferences, so I had to jump through some hoops right in KeyConfigPrefs::OnImport().
In general, I tried to keep changes minimal.
Comment 8 David Bailes 2021-01-28 21:24:54 UTC
(In reply to Leland Lucius from comment #7)
> I believe this was fixed by Binary Wisdom in commit:
> 
> https://github.com/audacity/audacity/commit/
> 9bce51a60ec23d09de5bbf9010bd3b98892dedc9
> 
> The fix follows the agreed behavior (see emails from around October 25) .
> For the sake of convenience see the agreed behavior below:
> 
> _"- first, check the xml-file. If it contains illegal shortcut duplicates,
> refuse importing. Shortcut duplicates are LEGAL if default settings also
> have those operations with the matching shortcuts. A refusal to import
> shortcuts must happen with the message that warns the user of a failure and
> explains the reason.
> 
> if the xml-file looks ok, import the shortcuts. As discussed before, because
> different versions of Audacity might have different sets of operations with
> shortcuts, it is still possible to end up with illegal shortcut duplicates
> for a perfectly correct xml-file. This situation must be monitored. In case
> of any conflicts, the shortcut from the xml-file is used, and the
> pre-existing shortcut is wiped clean.
> When telling the user the commands which have had their shortcut removed, I
> think it would be useful to tell the user the name of the command, the
> shortcut, and and name of the command which still has that shortcut."_
> 
> I didn't find a clean way to intercept the imported content before it makes
> its way to the shortcut preferences, so I had to jump through some hoops
> right in KeyConfigPrefs::OnImport().
> In general, I tried to keep changes minimal.

Apologies, I forgot to mark this as fixed. Have now done so.
Comment 9 Peter Sampson 2021-02-01 16:55:05 UTC
Created attachment 1077 [details]
error message for duplicates

Tested on W10 with Audacity 3.0.0 accd177

This tests OK on Windows.


Note that you can't test using Gale's steps as we no longer have CheckDep, the Check Dependencies was removed a while back
Comment 10 Peter Sampson 2021-02-01 17:08:38 UTC
(In reply to Leland Lucius from comment #7)

Tested on macOS 11.1 Big Sur with Audacity 3.0.0 accd177

This also tests OK on Mac.