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