From e8c8db8b332a49b145049ebd8dbe238dddd5406a Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 8 Jan 2020 16:33:09 -0500 Subject: [PATCH] Parent and dialog factory arguments of Effect::DoEffect are optional --- src/effects/Effect.cpp | 12 ++++++------ src/effects/Effect.h | 6 ++++-- src/effects/EffectUI.cpp | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 0e9d73729..c177cf034 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1096,11 +1096,11 @@ void Effect::SetBatchProcessing(bool start) } } -bool Effect::DoEffect(wxWindow &parent, - double projectRate, +bool Effect::DoEffect(double projectRate, TrackList *list, TrackFactory *factory, NotifyingSelectedRegion &selectedRegion, + wxWindow *pParent, const EffectDialogFactory &dialogFactory) { wxASSERT(selectedRegion.duration() >= 0.0); @@ -1187,9 +1187,9 @@ bool Effect::DoEffect(wxWindow &parent, // Prompting will be bypassed when applying an effect that has already // been configured, e.g. repeating the last effect on a different selection. // Prompting may call Effect::Preview - if ( dialogFactory && + if ( pParent && dialogFactory && IsInteractive() && - !ShowInterface(parent, dialogFactory, IsBatchProcessing()) ) + !ShowInterface( *pParent, dialogFactory, IsBatchProcessing() ) ) { return false; } @@ -1224,8 +1224,8 @@ bool Effect::Delegate( NotifyingSelectedRegion region; region.setTimes( mT0, mT1 ); - return delegate.DoEffect( parent, mProjectRate, mTracks, mFactory, - region, factory ); + return delegate.DoEffect( mProjectRate, mTracks, mFactory, + region, &parent, factory ); } // All legacy effects should have this overridden diff --git a/src/effects/Effect.h b/src/effects/Effect.h index b68edb2f1..2b7f10d28 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -255,9 +255,11 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, // have the "selected" flag set to true, which is consistent with // Audacity's standard UI. // Create a user interface only if the supplied function is not null. - /* not virtual */ bool DoEffect(wxWindow &parent, double projectRate, TrackList *list, + /* not virtual */ bool DoEffect( double projectRate, TrackList *list, TrackFactory *factory, NotifyingSelectedRegion &selectedRegion, - const EffectDialogFactory &dialogFactory ); + // Prompt the user for input only if these arguments are both not null. + wxWindow *pParent = nullptr, + const EffectDialogFactory &dialogFactory = {} ); bool Delegate( Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory ); diff --git a/src/effects/EffectUI.cpp b/src/effects/EffectUI.cpp index d33ed1046..98e0a7127 100644 --- a/src/effects/EffectUI.cpp +++ b/src/effects/EffectUI.cpp @@ -1924,11 +1924,12 @@ wxDialog *EffectUI::DialogFactory( wxWindow &parent, EffectHostInterface *pHost, EffectRack::Get( context.project ).Add(effect); } #endif - success = effect->DoEffect(window, + success = effect->DoEffect( rate, &tracks, &trackFactory, selectedRegion, + &window, (flags & EffectManager::kConfigured) == 0 ? DialogFactory : nullptr