mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
Eliminate calls to GetActiveProject in src/prefs
This commit is contained in:
parent
c3b32d1106
commit
f924df16f8
@ -80,8 +80,9 @@ BEGIN_EVENT_TABLE(KeyConfigPrefs, PrefsPanel)
|
||||
EVT_TIMER(FilterTimerID, KeyConfigPrefs::OnFilterTimer)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, wxWindowID winid,
|
||||
const CommandID &name)
|
||||
KeyConfigPrefs::KeyConfigPrefs(
|
||||
wxWindow * parent, wxWindowID winid, AudacityProject *pProject,
|
||||
const CommandID &name)
|
||||
/* i18n-hint: as in computer keyboard (not musical!) */
|
||||
: PrefsPanel(parent, winid, XO("Keyboard")),
|
||||
mView(NULL),
|
||||
@ -89,6 +90,7 @@ KeyConfigPrefs::KeyConfigPrefs(wxWindow * parent, wxWindowID winid,
|
||||
mFilter(NULL),
|
||||
mFilterTimer(this, FilterTimerID),
|
||||
mFilterPending(false)
|
||||
, mProject{ pProject }
|
||||
{
|
||||
Populate();
|
||||
if (!name.empty()) {
|
||||
@ -115,9 +117,8 @@ wxString KeyConfigPrefs::HelpPageName()
|
||||
void KeyConfigPrefs::Populate()
|
||||
{
|
||||
ShuttleGui S(this, eIsCreatingFromPrefs);
|
||||
AudacityProject *project = GetActiveProject();
|
||||
|
||||
if (!project) {
|
||||
if (!mProject) {
|
||||
S.StartVerticalLay(true);
|
||||
{
|
||||
S.StartStatic( {}, true);
|
||||
@ -136,7 +137,7 @@ void KeyConfigPrefs::Populate()
|
||||
|
||||
mCommandSelected = wxNOT_FOUND;
|
||||
|
||||
mManager = &CommandManager::Get( *project );
|
||||
mManager = &CommandManager::Get( *mProject );
|
||||
|
||||
// For speed, don't sort here. We're just creating.
|
||||
// Instead sort when we do SetView later in this function.
|
||||
@ -669,7 +670,7 @@ bool KeyConfigPrefs::Commit()
|
||||
// either. So we can't attempt to save preferences, otherwise
|
||||
// NULL ptr dereferences will happen in ShuttleGui because the
|
||||
// radio buttons are never created. (See Populate() above.)
|
||||
if (!GetActiveProject()) {
|
||||
if ( !mProject ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -714,10 +715,10 @@ void KeyConfigPrefs::Cancel()
|
||||
PrefsPanel::Factory
|
||||
KeyConfigPrefsFactory( const CommandID &name )
|
||||
{
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *pProject)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
auto result = safenew KeyConfigPrefs{ parent, winid, name };
|
||||
auto result = safenew KeyConfigPrefs{ parent, winid, pProject, name };
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
@ -32,7 +32,9 @@ enum ViewByType : int;
|
||||
class KeyConfigPrefs final : public PrefsPanel
|
||||
{
|
||||
public:
|
||||
KeyConfigPrefs(wxWindow * parent, wxWindowID winid, const CommandID &name);
|
||||
KeyConfigPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject,
|
||||
const CommandID &name);
|
||||
ComponentInterfaceSymbol GetSymbol() override;
|
||||
TranslatableString GetDescription() override;
|
||||
|
||||
@ -80,6 +82,8 @@ private:
|
||||
wxRadioButton *mViewByName;
|
||||
wxRadioButton *mViewByKey;
|
||||
|
||||
AudacityProject *mProject{};
|
||||
|
||||
CommandManager *mManager;
|
||||
int mCommandSelected;
|
||||
|
||||
|
@ -37,8 +37,10 @@
|
||||
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
|
||||
SpectrumPrefs::SpectrumPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt)
|
||||
SpectrumPrefs::SpectrumPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject, WaveTrack *wt)
|
||||
: PrefsPanel(parent, winid, wt ? XO("Spectrogram Settings") : XO("Spectrograms"))
|
||||
, mProject{ pProject }
|
||||
, mWt(wt)
|
||||
, mPopulating(false)
|
||||
{
|
||||
@ -429,9 +431,8 @@ void SpectrumPrefs::Rollback()
|
||||
}
|
||||
|
||||
if (isOpenPage) {
|
||||
auto pProject = ::GetActiveProject();
|
||||
if ( pProject ) {
|
||||
auto &tp = TrackPanel::Get ( *pProject );
|
||||
if ( mProject ) {
|
||||
auto &tp = TrackPanel::Get ( *mProject );
|
||||
tp.UpdateVRulers();
|
||||
tp.Refresh(false);
|
||||
}
|
||||
@ -480,9 +481,8 @@ void SpectrumPrefs::Preview()
|
||||
}
|
||||
|
||||
if (isOpenPage) {
|
||||
auto pProject = ::GetActiveProject();
|
||||
if ( pProject ) {
|
||||
auto &tp = TrackPanel::Get( *pProject );
|
||||
if ( mProject ) {
|
||||
auto &tp = TrackPanel::Get( *mProject );
|
||||
tp.UpdateVRulers();
|
||||
tp.Refresh(false);
|
||||
}
|
||||
@ -506,7 +506,7 @@ bool SpectrumPrefs::Commit()
|
||||
|
||||
bool SpectrumPrefs::ShowsPreviewButton()
|
||||
{
|
||||
return GetActiveProject() != nullptr;
|
||||
return mProject != nullptr;
|
||||
}
|
||||
|
||||
void SpectrumPrefs::OnControl(wxCommandEvent&)
|
||||
@ -588,9 +588,9 @@ END_EVENT_TABLE()
|
||||
PrefsPanel::Factory
|
||||
SpectrumPrefsFactory( WaveTrack *wt )
|
||||
{
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *pProject)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew SpectrumPrefs(parent, winid, wt);
|
||||
return safenew SpectrumPrefs(parent, winid, pProject, wt);
|
||||
};
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ struct WaveTrackSubViewPlacement;
|
||||
class SpectrumPrefs final : public PrefsPanel
|
||||
{
|
||||
public:
|
||||
SpectrumPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt);
|
||||
SpectrumPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject, WaveTrack *wt);
|
||||
virtual ~SpectrumPrefs();
|
||||
ComponentInterfaceSymbol GetSymbol() override;
|
||||
TranslatableString GetDescription() override;
|
||||
@ -71,6 +72,8 @@ class SpectrumPrefs final : public PrefsPanel
|
||||
|
||||
void EnableDisableSTFTOnlyControls();
|
||||
|
||||
AudacityProject *mProject{};
|
||||
|
||||
WaveTrack *const mWt;
|
||||
bool mDefaulted, mOrigDefaulted;
|
||||
|
||||
|
@ -30,9 +30,11 @@ Paul Licameli
|
||||
#include "../tracks/playabletrack/wavetrack/ui/WaveTrackView.h"
|
||||
#include "../tracks/playabletrack/wavetrack/ui/WaveTrackViewConstants.h"
|
||||
|
||||
WaveformPrefs::WaveformPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt)
|
||||
WaveformPrefs::WaveformPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject, WaveTrack *wt)
|
||||
/* i18n-hint: A waveform is a visual representation of vibration */
|
||||
: PrefsPanel(parent, winid, XO("Waveforms"))
|
||||
, mProject{ pProject }
|
||||
, mWt(wt)
|
||||
, mPopulating(false)
|
||||
{
|
||||
@ -191,9 +193,8 @@ bool WaveformPrefs::Commit()
|
||||
}
|
||||
|
||||
if (isOpenPage) {
|
||||
auto pProject = ::GetActiveProject();
|
||||
if ( pProject ) {
|
||||
auto &tp = TrackPanel::Get( *pProject );
|
||||
if ( mProject ) {
|
||||
auto &tp = TrackPanel::Get( *mProject );
|
||||
tp.UpdateVRulers();
|
||||
tp.Refresh(false);
|
||||
}
|
||||
@ -256,9 +257,9 @@ END_EVENT_TABLE()
|
||||
PrefsPanel::Factory
|
||||
WaveformPrefsFactory(WaveTrack *wt)
|
||||
{
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *)
|
||||
return [=](wxWindow *parent, wxWindowID winid, AudacityProject *pProject)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew WaveformPrefs(parent, winid, wt);
|
||||
return safenew WaveformPrefs(parent, winid, pProject, wt);
|
||||
};
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ class wxArrayStringEx;
|
||||
class WaveformPrefs final : public PrefsPanel
|
||||
{
|
||||
public:
|
||||
WaveformPrefs(wxWindow * parent, wxWindowID winid, WaveTrack *wt);
|
||||
WaveformPrefs(wxWindow * parent, wxWindowID winid,
|
||||
AudacityProject *pProject, WaveTrack *wt);
|
||||
virtual ~WaveformPrefs();
|
||||
ComponentInterfaceSymbol GetSymbol() override;
|
||||
TranslatableString GetDescription() override;
|
||||
@ -48,6 +49,8 @@ private:
|
||||
|
||||
void EnableDisableRange();
|
||||
|
||||
AudacityProject *mProject{};
|
||||
|
||||
WaveTrack *const mWt;
|
||||
bool mDefaulted;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user