From 8886d1ba41fb3875535cab9f75d0868002c4760b Mon Sep 17 00:00:00 2001 From: James Crook Date: Mon, 22 Aug 2016 13:25:05 +0100 Subject: [PATCH] Bug 1487 - Scrub and Seek are enabled when there is no audio to operate on I added a new flag, HasWaveDataFlag that checks not only for the presence of a WaveTrack but also for audio actually in it. This is now applied to the Scrub and Seek menu items, with the result that they grey out in the menu, and their buttons are dulled on the toolbar, if there is no audio. --- src/AudacityApp.h | 1 + src/Menus.cpp | 2 ++ src/tracks/ui/Scrubbing.cpp | 6 ++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/AudacityApp.h b/src/AudacityApp.h index ec888568a..4eacac2fc 100644 --- a/src/AudacityApp.h +++ b/src/AudacityApp.h @@ -97,6 +97,7 @@ enum CommandFlag : unsigned long long NotMinimizedFlag = 0x100000000ULL, // prl PausedFlag = 0x200000000ULL, // jkc NotPausedFlag = 0x400000000ULL, // jkc + HasWaveDataFlag = 0x800000000ULL, // jkc NoFlagsSpecifed = ~0ULL }; diff --git a/src/Menus.cpp b/src/Menus.cpp index 425120602..cfdfb9e8a 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -1736,6 +1736,8 @@ CommandFlag AudacityProject::GetUpdateFlags() flags |= WaveTracksSelectedFlag; } } + if( t->GetEndTime() > t->GetStartTime() ) + flags |= HasWaveDataFlag; } #if defined(USE_MIDI) else if (t->GetKind() == Track::Note) { diff --git a/src/tracks/ui/Scrubbing.cpp b/src/tracks/ui/Scrubbing.cpp index c32b61c26..310e195c5 100644 --- a/src/tracks/ui/Scrubbing.cpp +++ b/src/tracks/ui/Scrubbing.cpp @@ -233,12 +233,12 @@ namespace { "Seeking" is normal speed playback but with skips, ... */ { wxT("Scrub"), XO("&Scrub"), XO("Scrubbing"), - CaptureNotBusyFlag, + CaptureNotBusyFlag | HasWaveDataFlag, &Scrubber::OnScrub, false, &Scrubber::Scrubs, }, { wxT("Seek"), XO("See&k"), XO("Seeking"), - CaptureNotBusyFlag, + CaptureNotBusyFlag | HasWaveDataFlag, &Scrubber::OnSeek, true, &Scrubber::Seeks, }, @@ -859,6 +859,8 @@ Scrubber &ScrubbingOverlay::GetScrubber() void Scrubber::DoScrub(bool seek) { + if( !CanScrub() ) + return; const bool wasScrubbing = HasStartedScrubbing() || IsScrubbing(); const bool scroll = TracksPrefs::GetPinnedHeadPreference(); if (!wasScrubbing) {