From 71d5db448c632fbf598c6ee9a01646a433390531 Mon Sep 17 00:00:00 2001 From: Avery King Date: Thu, 29 Aug 2024 10:48:04 -0700 Subject: [PATCH] Prevent duplication of time tracks via track menu Previously, it was possible to duplicate a time track via the track options menu and clicking on "Duplicate Entire Track". However, Tenacity only allows one time track per project. This issue has now been fixed by checking for the presence of a time track. Signed-off-by: Avery King --- src/tracks/ui/CommonTrackControls.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tracks/ui/CommonTrackControls.cpp b/src/tracks/ui/CommonTrackControls.cpp index 5b03ee9982..79fdeb2c20 100644 --- a/src/tracks/ui/CommonTrackControls.cpp +++ b/src/tracks/ui/CommonTrackControls.cpp @@ -20,6 +20,7 @@ Paul Licameli split from TrackControls.cpp #include "Project.h" #include "../../ProjectHistory.h" #include "../../ProjectWindows.h" +#include "../../TimeTrack.h" #include "../../TrackArtist.h" #include "../../TrackInfo.h" #include "../../TrackPanelDrawingContext.h" @@ -29,6 +30,7 @@ Paul Licameli split from TrackControls.cpp #include "../../commands/AudacityCommand.h" #include "../../commands/CommandManager.h" #include "../../shuttle/ShuttleGui.h" +#include "../../widgets/AudacityMessageBox.h" #include "../../widgets/PopupMenuTable.h" #include @@ -263,6 +265,16 @@ void TrackMenuTable::OnDuplicateTrack(wxCommandEvent&) { TenacityProject& project = mpData->project; TrackList& tracks = TrackList::Get(project); + + if (*tracks.Any().begin()) + { + AudacityMessageBox( + XO("This version of Tenacity only allows one time track for each project window.") + ); + + return; + } + auto dupTrack = track->Duplicate(); tracks.Add(dupTrack);