1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 16:49:41 +02:00

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.
This commit is contained in:
Paul Licameli 2020-01-06 11:22:46 -05:00
parent 723c5256c0
commit ed9871d6b5

View File

@ -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()