From ed9871d6b51666be1b48fc52af853883a8a5d7dd Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 6 Jan 2020 11:22:46 -0500 Subject: [PATCH] Eliminate GetActiveProject in EffectUI.cpp... ... This changes visible behavior. If a realtime effect was open (say, AUGraphicEQ on Mac), and there were multiple projects, then the window was associated with one of the projects. But the "Apply" button could apply the effect to the active project, even if that was not the associated one. But the associated project was queried for the existence of a selection. Now, EffectUIHost::OnApply consistently examines and changes only the associated project, even if it is not active. You have to close the window and reopen it with the other project if you really want to change the other. You can't have two realtime effects open at once, even if for different projects. To overcome that limitation, we would have to make RealtimeEffectsManager store state per-project, not globally. --- src/effects/EffectUI.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/effects/EffectUI.cpp b/src/effects/EffectUI.cpp index 85c0d2225..d33ed1046 100644 --- a/src/effects/EffectUI.cpp +++ b/src/effects/EffectUI.cpp @@ -1131,6 +1131,8 @@ void EffectUIHost::OnClose(wxCloseEvent & WXUNUSED(evt)) void EffectUIHost::OnApply(wxCommandEvent & evt) { + auto &project = *mProject; + // On wxGTK (wx2.8.12), the default action is still executed even if // the button is disabled. This appears to affect all wxDialogs, not // just our Effects dialogs. So, this is a only temporary workaround @@ -1146,14 +1148,14 @@ void EffectUIHost::OnApply(wxCommandEvent & evt) mEffect && mEffect->GetType() != EffectTypeGenerate && mEffect->GetType() != EffectTypeTool && - ViewInfo::Get( *mProject ).selectedRegion.isPoint()) + ViewInfo::Get( project ).selectedRegion.isPoint()) { auto flags = AlwaysEnabledFlag; bool allowed = - MenuManager::Get(*mProject).ReportIfActionNotAllowed( - mEffect->GetName(), - flags, - WaveTracksSelectedFlag | TimeSelectedFlag); + MenuManager::Get( project ).ReportIfActionNotAllowed( + mEffect->GetName(), + flags, + WaveTracksSelectedFlag | TimeSelectedFlag); if (!allowed) return; } @@ -1194,7 +1196,6 @@ void EffectUIHost::OnApply(wxCommandEvent & evt) auto cleanup = finally( [&] { mApplyBtn->Enable(); } ); if( mEffect ) { - auto &project = *GetActiveProject(); CommandContext context( project ); // This is absolute hackage...but easy and I can't think of another way just now. // @@ -1206,7 +1207,7 @@ void EffectUIHost::OnApply(wxCommandEvent & evt) if( mCommand ) // PRL: I don't like the global and would rather pass *mProject! // But I am preserving old behavior - mCommand->Apply( CommandContext{ *GetActiveProject() } ); + mCommand->Apply( CommandContext{ project } ); } void EffectUIHost::DoCancel()