More uses of safenew for classes we derive from wxWindow classes...

... Also removed some unnecessary deletes of widgets that are managed by parent
windows
This commit is contained in:
Paul Licameli 2016-02-14 02:54:25 -05:00
parent 3f237daddc
commit df6a7c5464
70 changed files with 151 additions and 120 deletions

View File

@ -277,7 +277,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
S.StartVerticalLay(2); S.StartVerticalLay(2);
{ {
vRuler = new RulerPanel(this, wxID_ANY); vRuler = safenew RulerPanel(this, wxID_ANY);
vRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes vRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
vRuler->ruler.SetOrientation(wxVERTICAL); vRuler->ruler.SetOrientation(wxVERTICAL);
vRuler->ruler.SetRange(0.0, -dBRange); vRuler->ruler.SetRange(0.0, -dBRange);
@ -295,7 +295,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
} }
S.EndVerticalLay(); S.EndVerticalLay();
mFreqPlot = new FreqPlot(this); mFreqPlot = safenew FreqPlot(this);
mFreqPlot->SetMinSize(wxSize(wxDefaultCoord, FREQ_WINDOW_HEIGHT)); mFreqPlot->SetMinSize(wxSize(wxDefaultCoord, FREQ_WINDOW_HEIGHT));
S.Prop(1); S.Prop(1);
S.AddWindow(mFreqPlot, wxEXPAND); S.AddWindow(mFreqPlot, wxEXPAND);
@ -344,7 +344,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
S.StartHorizontalLay(wxEXPAND, 0); S.StartHorizontalLay(wxEXPAND, 0);
{ {
hRuler = new RulerPanel(this, wxID_ANY); hRuler = safenew RulerPanel(this, wxID_ANY);
hRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes hRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
hRuler->ruler.SetOrientation(wxHORIZONTAL); hRuler->ruler.SetOrientation(wxHORIZONTAL);
hRuler->ruler.SetLog(true); hRuler->ruler.SetLog(true);
@ -477,7 +477,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id,
S.AddSpace(5); S.AddSpace(5);
mProgress = new FreqGauge(this); //, wxID_ANY, wxST_SIZEGRIP); mProgress = safenew FreqGauge(this); //, wxID_ANY, wxST_SIZEGRIP);
S.AddWindow(mProgress, wxEXPAND); S.AddWindow(mProgress, wxEXPAND);
// Log-frequency axis works for spectrum plots only. // Log-frequency axis works for spectrum plots only.

View File

@ -93,7 +93,7 @@ Lyrics::Lyrics(wxWindow* parent, wxWindowID id,
this->SetBackgroundColour(*wxWHITE); this->SetBackgroundColour(*wxWHITE);
mHighlightTextCtrl = mHighlightTextCtrl =
new HighlightTextCtrl(this, -1, // wxWindow* parent, wxWindowID id, safenew HighlightTextCtrl(this, -1, // wxWindow* parent, wxWindowID id,
wxT(""), // const wxString& value = wxT(""), wxT(""), // const wxString& value = wxT(""),
wxPoint(0, 0), // const wxPoint& pos = wxDefaultPosition, wxPoint(0, 0), // const wxPoint& pos = wxDefaultPosition,
size); // const wxSize& size = wxDefaultSize size); // const wxSize& size = wxDefaultSize

View File

@ -113,7 +113,7 @@ LyricsWindow::LyricsWindow(AudacityProject *parent):
// //
//pToolBar->Realize(); //pToolBar->Realize();
mLyricsPanel = new Lyrics(this, -1, panelPos, panelSize); mLyricsPanel = safenew Lyrics(this, -1, panelPos, panelSize);
//vvv Highlight style is broken in ported version. //vvv Highlight style is broken in ported version.
//switch (mLyricsPanel->GetLyricsStyle()) //switch (mLyricsPanel->GetLyricsStyle())

View File

@ -5255,7 +5255,7 @@ void AudacityProject::OnHistory()
void AudacityProject::OnKaraoke() void AudacityProject::OnKaraoke()
{ {
if (!mLyricsWindow) if (!mLyricsWindow)
mLyricsWindow = new LyricsWindow(this); mLyricsWindow = safenew LyricsWindow(this);
mLyricsWindow->Show(); mLyricsWindow->Show();
UpdateLyrics(); UpdateLyrics();
mLyricsWindow->Raise(); mLyricsWindow->Raise();
@ -5265,7 +5265,7 @@ void AudacityProject::OnMixerBoard()
{ {
if (!mMixerBoardFrame) if (!mMixerBoardFrame)
{ {
mMixerBoardFrame = new MixerBoardFrame(this); mMixerBoardFrame = safenew MixerBoardFrame(this);
mMixerBoard = mMixerBoardFrame->mMixerBoard; mMixerBoard = mMixerBoardFrame->mMixerBoard;
} }
mMixerBoardFrame->Show(); mMixerBoardFrame->Show();

View File

@ -209,7 +209,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
#ifdef EXPERIMENTAL_MIDI_OUT #ifdef EXPERIMENTAL_MIDI_OUT
if (mNoteTrack) { if (mNoteTrack) {
mSlider_Gain = mSlider_Gain =
new MixerTrackSlider( safenew MixerTrackSlider(
this, ID_SLIDER_GAIN, this, ID_SLIDER_GAIN,
/* i18n-hint: title of the MIDI Velocity slider */ /* i18n-hint: title of the MIDI Velocity slider */
_("Velocity"), _("Velocity"),
@ -218,7 +218,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
} else } else
#endif #endif
mSlider_Gain = mSlider_Gain =
new MixerTrackSlider( safenew MixerTrackSlider(
this, ID_SLIDER_GAIN, this, ID_SLIDER_GAIN,
/* i18n-hint: title of the Gain slider, used to adjust the volume */ /* i18n-hint: title of the Gain slider, used to adjust the volume */
_("Gain"), _("Gain"),
@ -258,7 +258,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
ctrlSize.x--; ctrlSize.x--;
mSlider_Pan = mSlider_Pan =
new MixerTrackSlider( safenew MixerTrackSlider(
this, ID_SLIDER_PAN, this, ID_SLIDER_PAN,
/* i18n-hint: Title of the Pan slider, used to move the sound left or right */ /* i18n-hint: Title of the Pan slider, used to move the sound left or right */
_("Pan"), _("Pan"),
@ -271,7 +271,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
ctrlPos.y += PAN_HEIGHT + kDoubleInset; ctrlPos.y += PAN_HEIGHT + kDoubleInset;
ctrlSize.Set(mMixerBoard->mMuteSoloWidth, MUTE_SOLO_HEIGHT); ctrlSize.Set(mMixerBoard->mMuteSoloWidth, MUTE_SOLO_HEIGHT);
mToggleButton_Mute = mToggleButton_Mute =
new AButton(this, ID_TOGGLEBUTTON_MUTE, safenew AButton(this, ID_TOGGLEBUTTON_MUTE,
ctrlPos, ctrlSize, ctrlPos, ctrlSize,
*(mMixerBoard->mImageMuteUp), *(mMixerBoard->mImageMuteOver), *(mMixerBoard->mImageMuteUp), *(mMixerBoard->mImageMuteOver),
*(mMixerBoard->mImageMuteDown), *(mMixerBoard->mImageMuteDisabled), *(mMixerBoard->mImageMuteDown), *(mMixerBoard->mImageMuteDisabled),
@ -285,7 +285,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
ctrlPos.y += MUTE_SOLO_HEIGHT; ctrlPos.y += MUTE_SOLO_HEIGHT;
mToggleButton_Solo = mToggleButton_Solo =
new AButton(this, ID_TOGGLEBUTTON_SOLO, safenew AButton(this, ID_TOGGLEBUTTON_SOLO,
ctrlPos, ctrlSize, ctrlPos, ctrlSize,
*(mMixerBoard->mImageSoloUp), *(mMixerBoard->mImageSoloOver), *(mMixerBoard->mImageSoloUp), *(mMixerBoard->mImageSoloOver),
*(mMixerBoard->mImageSoloDown), *(mMixerBoard->mImageSoloDisabled), *(mMixerBoard->mImageSoloDown), *(mMixerBoard->mImageSoloDisabled),
@ -308,7 +308,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent,
if (mLeftTrack) { if (mLeftTrack) {
#endif #endif
mMeter = mMeter =
new Meter(GetActiveProject(), // AudacityProject* project, safenew Meter(GetActiveProject(), // AudacityProject* project,
this, -1, // wxWindow* parent, wxWindowID id, this, -1, // wxWindow* parent, wxWindowID id,
false, // bool isInput false, // bool isInput
ctrlPos, ctrlSize, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, ctrlPos, ctrlSize, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
@ -984,7 +984,7 @@ MixerBoard::MixerBoard(AudacityProject* pProject,
mProject = pProject; mProject = pProject;
mScrolledWindow = mScrolledWindow =
new MixerBoardScrolledWindow( safenew MixerBoardScrolledWindow(
pProject, // AudacityProject* project, pProject, // AudacityProject* project,
this, -1, // wxWindow* parent, wxWindowID id = -1, this, -1, // wxWindow* parent, wxWindowID id = -1,
this->GetClientAreaOrigin(), // const wxPoint& pos = wxDefaultPosition, this->GetClientAreaOrigin(), // const wxPoint& pos = wxDefaultPosition,
@ -1109,7 +1109,7 @@ void MixerBoard::UpdateTrackClusters()
kInset); kInset);
wxSize clusterSize(kMixerTrackClusterWidth, nClusterHeight); wxSize clusterSize(kMixerTrackClusterWidth, nClusterHeight);
pMixerTrackCluster = pMixerTrackCluster =
new MixerTrackCluster(mScrolledWindow, this, mProject, safenew MixerTrackCluster(mScrolledWindow, this, mProject,
(WaveTrack*)pLeftTrack, (WaveTrack*)pRightTrack, (WaveTrack*)pLeftTrack, (WaveTrack*)pRightTrack,
clusterPos, clusterSize); clusterPos, clusterSize);
if (pMixerTrackCluster) if (pMixerTrackCluster)
@ -1758,7 +1758,7 @@ MixerBoardFrame::MixerBoardFrame(AudacityProject* parent)
// wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT) // wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT)
wxDEFAULT_FRAME_STYLE) wxDEFAULT_FRAME_STYLE)
{ {
mMixerBoard = new MixerBoard(parent, this, wxDefaultPosition, kDefaultSize); mMixerBoard = safenew MixerBoard(parent, this, wxDefaultPosition, kDefaultSize);
this->SetSizeHints(MIXER_BOARD_MIN_WIDTH, MIXER_BOARD_MIN_HEIGHT); this->SetSizeHints(MIXER_BOARD_MIN_WIDTH, MIXER_BOARD_MIN_HEIGHT);

View File

@ -897,7 +897,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
// //
// Create the horizontal ruler // Create the horizontal ruler
// //
mRuler = new AdornedRulerPanel( this, mRuler = safenew AdornedRulerPanel( this,
wxID_ANY, wxID_ANY,
wxDefaultPosition, wxDefaultPosition,
wxSize( -1, AdornedRulerPanel::GetRulerHeight() ), wxSize( -1, AdornedRulerPanel::GetRulerHeight() ),
@ -962,8 +962,8 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
// will be given the focus even if we try to SetFocus(). By // will be given the focus even if we try to SetFocus(). By
// creating the scrollbars after the TrackPanel, we resolve // creating the scrollbars after the TrackPanel, we resolve
// several focus problems. // several focus problems.
mHsbar = new ScrollBar(pPage, HSBarID, wxSB_HORIZONTAL); mHsbar = safenew ScrollBar(pPage, HSBarID, wxSB_HORIZONTAL);
mVsbar = new ScrollBar(pPage, VSBarID, wxSB_VERTICAL); mVsbar = safenew ScrollBar(pPage, VSBarID, wxSB_VERTICAL);
// LLL: When Audacity starts or becomes active after returning from // LLL: When Audacity starts or becomes active after returning from
// another application, the first window that can accept focus // another application, the first window that can accept focus

View File

@ -2077,8 +2077,8 @@ RulerPanel * ShuttleGui::AddRulerVertical(float low, float hi, const wxString &
// return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), RulerPanel); // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), RulerPanel);
RulerPanel * pRulerPanel; RulerPanel * pRulerPanel;
miProp=0; miProp=0;
mpWind = pRulerPanel = new RulerPanel( mpWind = pRulerPanel = safenew RulerPanel(
mpParent, GetParent(),
miId, miId,
wxDefaultPosition, wxDefaultPosition,
wxDefaultSize wxDefaultSize

View File

@ -54,7 +54,7 @@ void TimeDialog::PopulateOrExchange(ShuttleGui &S)
{ {
S.StartStatic(mPrompt, true); S.StartStatic(mPrompt, true);
{ {
mTimeCtrl = new mTimeCtrl = safenew
NumericTextCtrl( NumericTextCtrl(
NumericConverter::TIME, this, NumericConverter::TIME, this,
wxID_ANY, wxID_ANY,

View File

@ -364,7 +364,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
m_pDatePickerCtrl_Start->SetRange(wxDateTime::Today(), wxInvalidDateTime); // No backdating. m_pDatePickerCtrl_Start->SetRange(wxDateTime::Today(), wxInvalidDateTime); // No backdating.
S.AddWindow(m_pDatePickerCtrl_Start); S.AddWindow(m_pDatePickerCtrl_Start);
m_pTimeTextCtrl_Start = new NumericTextCtrl( m_pTimeTextCtrl_Start = safenew NumericTextCtrl(
NumericConverter::TIME, this, ID_TIMETEXT_START); NumericConverter::TIME, this, ID_TIMETEXT_START);
m_pTimeTextCtrl_Start->SetName(_("Start Time")); m_pTimeTextCtrl_Start->SetName(_("Start Time"));
m_pTimeTextCtrl_Start->SetFormatString(strFormat); m_pTimeTextCtrl_Start->SetFormatString(strFormat);
@ -386,7 +386,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
m_pDatePickerCtrl_End->SetName(_("End Date")); m_pDatePickerCtrl_End->SetName(_("End Date"));
S.AddWindow(m_pDatePickerCtrl_End); S.AddWindow(m_pDatePickerCtrl_End);
m_pTimeTextCtrl_End = new NumericTextCtrl( m_pTimeTextCtrl_End = safenew NumericTextCtrl(
NumericConverter::TIME, this, ID_TIMETEXT_END); NumericConverter::TIME, this, ID_TIMETEXT_END);
m_pTimeTextCtrl_End->SetName(_("End Time")); m_pTimeTextCtrl_End->SetName(_("End Time"));
m_pTimeTextCtrl_End->SetFormatString(strFormat); m_pTimeTextCtrl_End->SetFormatString(strFormat);
@ -407,7 +407,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S)
* seconds. * seconds.
*/ */
wxString strFormat1 = _("099 days 024 h 060 m 060 s"); wxString strFormat1 = _("099 days 024 h 060 m 060 s");
m_pTimeTextCtrl_Duration = new NumericTextCtrl( m_pTimeTextCtrl_Duration = safenew NumericTextCtrl(
NumericConverter::TIME, this, ID_TIMETEXT_DURATION); NumericConverter::TIME, this, ID_TIMETEXT_DURATION);
m_pTimeTextCtrl_Duration->SetName(_("Duration")); m_pTimeTextCtrl_Duration->SetName(_("Duration"));
m_pTimeTextCtrl_Duration->SetFormatString(strFormat1); m_pTimeTextCtrl_Duration->SetFormatString(strFormat1);

View File

@ -10065,7 +10065,8 @@ static TrackPanel * TrackPanelFactory(wxWindow * parent,
TrackPanelListener * listener, TrackPanelListener * listener,
AdornedRulerPanel * ruler) AdornedRulerPanel * ruler)
{ {
return new TrackPanel( wxASSERT(parent); // to justify safenew
return safenew TrackPanel(
parent, parent,
id, id,
pos, pos,

View File

@ -515,6 +515,7 @@ public:
TrackPanelListener * GetListener(){ return mListener;} TrackPanelListener * GetListener(){ return mListener;}
AdornedRulerPanel * GetRuler(){ return mRuler;} AdornedRulerPanel * GetRuler(){ return mRuler;}
// JKC and here is a factory function which just does 'NEW' in standard Audacity. // JKC and here is a factory function which just does 'NEW' in standard Audacity.
// Precondition: parent != NULL
static TrackPanel *(*FactoryFunction)(wxWindow * parent, static TrackPanel *(*FactoryFunction)(wxWindow * parent,
wxWindowID id, wxWindowID id,
const wxPoint & pos, const wxPoint & pos,

View File

@ -424,7 +424,7 @@ void EffectAutoDuck::PopulateOrExchange(ShuttleGui & S)
{ {
S.AddSpace(0, 5); S.AddSpace(0, 5);
mPanel = new EffectAutoDuckPanel(S.GetParent(), this); mPanel = safenew EffectAutoDuckPanel(S.GetParent(), this);
S.AddWindow(mPanel); S.AddWindow(mPanel);
S.AddSpace(0, 5); S.AddSpace(0, 5);

View File

@ -362,7 +362,7 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S)
{ {
S.AddPrompt(_("Current Length:")); S.AddPrompt(_("Current Length:"));
mpFromLengthCtrl = new mpFromLengthCtrl = safenew
NumericTextCtrl(NumericConverter::TIME, NumericTextCtrl(NumericConverter::TIME,
S.GetParent(), S.GetParent(),
wxID_ANY, wxID_ANY,
@ -378,7 +378,7 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S)
S.AddPrompt(_("New Length:")); S.AddPrompt(_("New Length:"));
mpToLengthCtrl = new mpToLengthCtrl = safenew
NumericTextCtrl(NumericConverter::TIME, NumericTextCtrl(NumericConverter::TIME,
S.GetParent(), S.GetParent(),
ID_ToLength, ID_ToLength,

View File

@ -205,7 +205,7 @@ void EffectCompressor::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(wxEXPAND, true); S.StartHorizontalLay(wxEXPAND, true);
{ {
S.SetBorder(10); S.SetBorder(10);
mPanel = new EffectCompressorPanel(S.GetParent(), mPanel = safenew EffectCompressorPanel(S.GetParent(),
mThresholdDB, mThresholdDB,
mNoiseFloorDB, mNoiseFloorDB,
mRatio); mRatio);

View File

@ -226,7 +226,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
S.AddFixedText(_("&Foreground:"), false); S.AddFixedText(_("&Foreground:"), false);
if (S.GetMode() == eIsCreating) if (S.GetMode() == eIsCreating)
{ {
mForegroundStartT = new mForegroundStartT = safenew
NumericTextCtrl(NumericConverter::TIME, this, NumericTextCtrl(NumericConverter::TIME, this,
ID_FOREGROUNDSTART_T, ID_FOREGROUNDSTART_T,
_("hh:mm:ss + hundredths"), _("hh:mm:ss + hundredths"),
@ -242,7 +242,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
if (S.GetMode() == eIsCreating) if (S.GetMode() == eIsCreating)
{ {
mForegroundEndT = new mForegroundEndT = safenew
NumericTextCtrl(NumericConverter::TIME, this, NumericTextCtrl(NumericConverter::TIME, this,
ID_FOREGROUNDEND_T, ID_FOREGROUNDEND_T,
_("hh:mm:ss + hundredths"), _("hh:mm:ss + hundredths"),
@ -264,7 +264,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
S.AddFixedText(_("&Background:")); S.AddFixedText(_("&Background:"));
if (S.GetMode() == eIsCreating) if (S.GetMode() == eIsCreating)
{ {
mBackgroundStartT = new mBackgroundStartT = safenew
NumericTextCtrl(NumericConverter::TIME, this, NumericTextCtrl(NumericConverter::TIME, this,
ID_BACKGROUNDSTART_T, ID_BACKGROUNDSTART_T,
_("hh:mm:ss + hundredths"), _("hh:mm:ss + hundredths"),
@ -280,7 +280,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id,
if (S.GetMode() == eIsCreating) if (S.GetMode() == eIsCreating)
{ {
mBackgroundEndT = new mBackgroundEndT = safenew
NumericTextCtrl(NumericConverter::TIME, this, NumericTextCtrl(NumericConverter::TIME, this,
ID_BACKGROUNDEND_T, ID_BACKGROUNDEND_T,
_("hh:mm:ss + hundredths"), _("hh:mm:ss + hundredths"),

View File

@ -312,7 +312,7 @@ void EffectDtmf::PopulateOrExchange(ShuttleGui & S)
S.Id(ID_Amplitude).AddTextBox(_("Amplitude (0-1):"), wxT(""), 10)->SetValidator(vldAmp); S.Id(ID_Amplitude).AddTextBox(_("Amplitude (0-1):"), wxT(""), 10)->SetValidator(vldAmp);
S.AddPrompt(_("Duration:")); S.AddPrompt(_("Duration:"));
mDtmfDurationT = new mDtmfDurationT = safenew
NumericTextCtrl(NumericConverter::TIME, NumericTextCtrl(NumericConverter::TIME,
S.GetParent(), S.GetParent(),
ID_Duration, ID_Duration,

View File

@ -2884,7 +2884,7 @@ bool EffectUIHost::Initialize()
wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL); wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL);
EffectPanel *w = new EffectPanel(this); EffectPanel *w = safenew EffectPanel(this);
// Try to give the window a sensible default/minimum size // Try to give the window a sensible default/minimum size
w->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3), w->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3),

View File

@ -342,7 +342,10 @@ EffectRack *EffectManager::GetRack()
{ {
if (!mRack) if (!mRack)
{ {
mRack = new EffectRack(); // EffectRack is constructed with the current project as owner, so safenew is OK
mRack = safenew EffectRack();
// Make sure what I just commented remains true:
wxASSERT(mRack->GetParent());
mRack->CenterOnParent(); mRack->CenterOnParent();
} }

View File

@ -599,7 +599,7 @@ bool EffectEqualization::CloseUI()
void EffectEqualization::PopulateOrExchange(ShuttleGui & S) void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
{ {
wxWindow *parent = S.GetParent(); wxWindow *const parent = S.GetParent();
LoadCurves(); LoadCurves();
@ -634,7 +634,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
// ------------------------------------------------------------------- // -------------------------------------------------------------------
S.StartVerticalLay(); S.StartVerticalLay();
{ {
mdBRuler = new RulerPanel(parent, wxID_ANY); mdBRuler = safenew RulerPanel(parent, wxID_ANY);
mdBRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes mdBRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
mdBRuler->ruler.SetOrientation(wxVERTICAL); mdBRuler->ruler.SetOrientation(wxVERTICAL);
mdBRuler->ruler.SetRange(60.0, -120.0); mdBRuler->ruler.SetRange(60.0, -120.0);
@ -653,7 +653,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
} }
S.EndVerticalLay(); S.EndVerticalLay();
mPanel = new EqualizationPanel(this, parent); mPanel = safenew EqualizationPanel(this, parent);
S.Prop(1); S.Prop(1);
S.AddWindow(mPanel, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP); S.AddWindow(mPanel, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP);
S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); S.SetSizeHints(wxDefaultCoord, wxDefaultCoord);
@ -687,7 +687,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S)
// Column 1 is empty // Column 1 is empty
S.AddSpace(1, 1); S.AddSpace(1, 1);
mFreqRuler = new RulerPanel(parent, wxID_ANY); mFreqRuler = safenew RulerPanel(parent, wxID_ANY);
mFreqRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes mFreqRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
mFreqRuler->ruler.SetOrientation(wxHORIZONTAL); mFreqRuler->ruler.SetOrientation(wxHORIZONTAL);
mFreqRuler->ruler.SetLog(true); mFreqRuler->ruler.SetLog(true);

View File

@ -225,7 +225,7 @@ void EffectNoise::PopulateOrExchange(ShuttleGui & S)
S.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12)->SetValidator(vldAmp); S.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12)->SetValidator(vldAmp);
S.AddPrompt(_("Duration:")); S.AddPrompt(_("Duration:"));
mNoiseDurationT = new mNoiseDurationT = safenew
NumericTextCtrl(NumericConverter::TIME, NumericTextCtrl(NumericConverter::TIME,
S.GetParent(), S.GetParent(),
wxID_ANY, wxID_ANY,

View File

@ -363,7 +363,7 @@ bool EffectScienFilter::Init()
void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
{ {
wxWindow *parent = S.GetParent(); wxWindow *const parent = S.GetParent();
S.AddSpace(5); S.AddSpace(5);
S.SetSizerProportion(1); S.SetSizerProportion(1);
@ -378,7 +378,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
S.StartVerticalLay(); S.StartVerticalLay();
{ {
mdBRuler = new RulerPanel(parent, wxID_ANY); mdBRuler = safenew RulerPanel(parent, wxID_ANY);
mdBRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes mdBRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
mdBRuler->ruler.SetOrientation(wxVERTICAL); mdBRuler->ruler.SetOrientation(wxVERTICAL);
mdBRuler->ruler.SetRange(30.0, -120.0); mdBRuler->ruler.SetRange(30.0, -120.0);
@ -397,7 +397,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
} }
S.EndVerticalLay(); S.EndVerticalLay();
mPanel = new EffectScienFilterPanel(this, parent); mPanel = safenew EffectScienFilterPanel(this, parent);
mPanel->SetFreqRange(mLoFreq, mNyquist); mPanel->SetFreqRange(mLoFreq, mNyquist);
S.SetBorder(5); S.SetBorder(5);
@ -431,7 +431,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S)
S.AddSpace(1, 1); S.AddSpace(1, 1);
mfreqRuler = new RulerPanel(parent, wxID_ANY); mfreqRuler = safenew RulerPanel(parent, wxID_ANY);
mfreqRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes mfreqRuler->ruler.SetBounds(0, 0, 100, 100); // Ruler can't handle small sizes
mfreqRuler->ruler.SetOrientation(wxHORIZONTAL); mfreqRuler->ruler.SetOrientation(wxHORIZONTAL);
mfreqRuler->ruler.SetLog(true); mfreqRuler->ruler.SetLog(true);

View File

@ -58,7 +58,7 @@ void EffectSilence::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(); S.StartHorizontalLay();
{ {
S.AddPrompt(_("Duration:")); S.AddPrompt(_("Duration:"));
mDurationT = new mDurationT = safenew
NumericTextCtrl(NumericConverter::TIME, NumericTextCtrl(NumericConverter::TIME,
S.GetParent(), S.GetParent(),
wxID_ANY, wxID_ANY,

View File

@ -395,7 +395,7 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S)
} }
S.AddPrompt(_("Duration:")); S.AddPrompt(_("Duration:"));
mToneDurationT = new mToneDurationT = safenew
NumericTextCtrl(NumericConverter::TIME, NumericTextCtrl(NumericConverter::TIME,
S.GetParent(), S.GetParent(),
wxID_ANY, wxID_ANY,

View File

@ -2884,7 +2884,7 @@ void VSTEffect::BuildPlain()
{ {
wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:")); wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:"));
gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
mDuration = new mDuration = safenew
NumericTextCtrl(NumericConverter::TIME, NumericTextCtrl(NumericConverter::TIME,
scroller, scroller,
ID_Duration, ID_Duration,

View File

@ -1196,7 +1196,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
{ {
item = safenew wxStaticText(w, 0, _("Duration:")); item = safenew wxStaticText(w, 0, _("Duration:"));
gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
mDuration = new mDuration = safenew
NumericTextCtrl(NumericConverter::TIME, NumericTextCtrl(NumericConverter::TIME,
w, w,
ID_Duration, ID_Duration,
@ -1431,7 +1431,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent)
upper = floorf(upper * 1000000.0) / 1000000.0; upper = floorf(upper * 1000000.0) / 1000000.0;
mInputControls[p] = roundf(mInputControls[p] * 1000000.0) / 1000000.0; mInputControls[p] = roundf(mInputControls[p] * 1000000.0) / 1000000.0;
mMeters[p] = new LadspaEffectMeter(w, mOutputControls[p], lower, upper); mMeters[p] = safenew LadspaEffectMeter(w, mOutputControls[p], lower, upper);
mMeters[p]->SetName(labelText); mMeters[p]->SetName(labelText);
gridSizer->Add(mMeters[p], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5); gridSizer->Add(mMeters[p], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5);
} }

View File

@ -1604,7 +1604,7 @@ bool LV2Effect::BuildPlain()
wxWindow *item = safenew wxStaticText(w, 0, _("&Duration:")); wxWindow *item = safenew wxStaticText(w, 0, _("&Duration:"));
sizer->Add(item, 0, wxALIGN_CENTER | wxALL, 5); sizer->Add(item, 0, wxALIGN_CENTER | wxALL, 5);
mDuration = new mDuration = safenew
NumericTextCtrl(NumericConverter::TIME, NumericTextCtrl(NumericConverter::TIME,
w, w,
ID_Duration, ID_Duration,
@ -1707,7 +1707,7 @@ bool LV2Effect::BuildPlain()
{ {
gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0);
gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0);
LV2EffectMeter *m = new LV2EffectMeter(w, ctrl); LV2EffectMeter *m = safenew LV2EffectMeter(w, ctrl);
gridSizer->Add(m, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND); gridSizer->Add(m, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND);
gridSizer->Add(1, 1, 0); gridSizer->Add(1, 1, 0);
} }

View File

@ -1216,7 +1216,7 @@ ExportMixerDialog::ExportMixerDialog( TrackList *tracks, bool selectedOnly,
wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL );
wxWindow *mixerPanel = new ExportMixerPanel( mMixerSpec, mTrackNames, this, wxWindow *mixerPanel = safenew ExportMixerPanel( mMixerSpec, mTrackNames, this,
ID_MIXERPANEL, wxDefaultPosition, wxSize( 400, -1 ) ); ID_MIXERPANEL, wxDefaultPosition, wxSize( 400, -1 ) );
mixerPanel->SetName(_("Mixer Panel")); mixerPanel->SetName(_("Mixer Panel"));
vertSizer->Add( mixerPanel, 1, wxEXPAND | wxALIGN_CENTRE | wxALL, 5 ); vertSizer->Add( mixerPanel, 1, wxEXPAND | wxALIGN_CENTRE | wxALL, 5 );

View File

@ -83,8 +83,9 @@ public:
virtual bool IsExtension(const wxString & ext, int index); virtual bool IsExtension(const wxString & ext, int index);
virtual bool DisplayOptions(wxWindow *parent, int format = 0); virtual bool DisplayOptions(wxWindow *parent, int format = 0);
virtual wxWindow *OptionsCreate(wxWindow *parent, int format); // Precondition: parent != NULL
virtual wxWindow *OptionsCreate(wxWindow *parent, int format) = 0;
virtual bool CheckFileName(wxFileName &filename, int format = 0); virtual bool CheckFileName(wxFileName &filename, int format = 0);

View File

@ -536,7 +536,8 @@ int ExportCL::Export(AudacityProject *project,
wxWindow *ExportCL::OptionsCreate(wxWindow *parent, int format) wxWindow *ExportCL::OptionsCreate(wxWindow *parent, int format)
{ {
return new ExportCLOptions(parent, format); wxASSERT(parent); // to justify safenew
return safenew ExportCLOptions(parent, format);
} }
ExportPlugin *New_ExportCL() ExportPlugin *New_ExportCL()

View File

@ -983,27 +983,28 @@ int ExportFFmpeg::AskResample(int bitrate, int rate, int lowrate, int highrate,
wxWindow *ExportFFmpeg::OptionsCreate(wxWindow *parent, int format) wxWindow *ExportFFmpeg::OptionsCreate(wxWindow *parent, int format)
{ {
wxASSERT(parent); // to justify safenew
// subformat index may not correspond directly to fmts[] index, convert it // subformat index may not correspond directly to fmts[] index, convert it
mSubFormat = AdjustFormatIndex(format); mSubFormat = AdjustFormatIndex(format);
if (mSubFormat == FMT_M4A) if (mSubFormat == FMT_M4A)
{ {
return new ExportFFmpegAACOptions(parent, format); return safenew ExportFFmpegAACOptions(parent, format);
} }
else if (mSubFormat == FMT_AC3) else if (mSubFormat == FMT_AC3)
{ {
return new ExportFFmpegAC3Options(parent, format); return safenew ExportFFmpegAC3Options(parent, format);
} }
else if (mSubFormat == FMT_AMRNB) else if (mSubFormat == FMT_AMRNB)
{ {
return new ExportFFmpegAMRNBOptions(parent, format); return safenew ExportFFmpegAMRNBOptions(parent, format);
} }
else if (mSubFormat == FMT_WMA2) else if (mSubFormat == FMT_WMA2)
{ {
return new ExportFFmpegWMAOptions(parent, format); return safenew ExportFFmpegWMAOptions(parent, format);
} }
else if (mSubFormat == FMT_OTHER) else if (mSubFormat == FMT_OTHER)
{ {
return new ExportFFmpegCustomOptions(parent, format); return safenew ExportFFmpegCustomOptions(parent, format);
} }
return ExportPlugin::OptionsCreate(parent, format); return ExportPlugin::OptionsCreate(parent, format);

View File

@ -370,7 +370,8 @@ int ExportFLAC::Export(AudacityProject *project,
wxWindow *ExportFLAC::OptionsCreate(wxWindow *parent, int format) wxWindow *ExportFLAC::OptionsCreate(wxWindow *parent, int format)
{ {
return new ExportFLACOptions(parent, format); wxASSERT(parent); // to justify safenew
return safenew ExportFLACOptions(parent, format);
} }
// LL: There's a bug in libflac++ 1.1.2 that prevents us from using // LL: There's a bug in libflac++ 1.1.2 that prevents us from using

View File

@ -334,7 +334,8 @@ int ExportMP2::Export(AudacityProject *project,
wxWindow *ExportMP2::OptionsCreate(wxWindow *parent, int format) wxWindow *ExportMP2::OptionsCreate(wxWindow *parent, int format)
{ {
return new ExportMP2Options(parent, format); wxASSERT(parent); // to justify safenew
return safenew ExportMP2Options(parent, format);
} }
// returns buffer len; caller frees // returns buffer len; caller frees

View File

@ -1869,7 +1869,8 @@ int ExportMP3::Export(AudacityProject *project,
wxWindow *ExportMP3::OptionsCreate(wxWindow *parent, int format) wxWindow *ExportMP3::OptionsCreate(wxWindow *parent, int format)
{ {
return new ExportMP3Options(parent, format); wxASSERT(parent); // to justify safenew
return safenew ExportMP3Options(parent, format);
} }
int ExportMP3::FindValue(CHOICES *choices, int cnt, int needle, int def) int ExportMP3::FindValue(CHOICES *choices, int cnt, int needle, int def)

View File

@ -337,7 +337,8 @@ int ExportOGG::Export(AudacityProject *project,
wxWindow *ExportOGG::OptionsCreate(wxWindow *parent, int format) wxWindow *ExportOGG::OptionsCreate(wxWindow *parent, int format)
{ {
return new ExportOGGOptions(parent, format); wxASSERT(parent); // to justify safenew
return safenew ExportOGGOptions(parent, format);
} }
bool ExportOGG::FillComment(AudacityProject *project, vorbis_comment *comment, Tags *metadata) bool ExportOGG::FillComment(AudacityProject *project, vorbis_comment *comment, Tags *metadata)

View File

@ -877,10 +877,11 @@ void ExportPCM::AddID3Chunk(wxString fName, Tags *tags, int sf_format)
wxWindow *ExportPCM::OptionsCreate(wxWindow *parent, int format) wxWindow *ExportPCM::OptionsCreate(wxWindow *parent, int format)
{ {
wxASSERT(parent); // to justify safenew
// default, full user control // default, full user control
if (format < 0 || format >= WXSIZEOF(kFormats)) if (format < 0 || format >= WXSIZEOF(kFormats))
{ {
return new ExportPCMOptions(parent, format); return safenew ExportPCMOptions(parent, format);
} }
return ExportPlugin::OptionsCreate(parent, format); return ExportPlugin::OptionsCreate(parent, format);

View File

@ -84,5 +84,6 @@ BatchPrefs::~BatchPrefs()
PrefsPanel *BatchPrefsFactory::Create(wxWindow *parent) PrefsPanel *BatchPrefsFactory::Create(wxWindow *parent)
{ {
return new BatchPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew BatchPrefs(parent);
} }

View File

@ -374,5 +374,6 @@ bool DevicePrefs::Apply()
PrefsPanel *DevicePrefsFactory::Create(wxWindow *parent) PrefsPanel *DevicePrefsFactory::Create(wxWindow *parent)
{ {
return new DevicePrefs(parent); wxASSERT(parent); // to justify safenew
return safenew DevicePrefs(parent);
} }

View File

@ -266,5 +266,6 @@ bool DirectoriesPrefs::Apply()
PrefsPanel *DirectoriesPrefsFactory::Create(wxWindow *parent) PrefsPanel *DirectoriesPrefsFactory::Create(wxWindow *parent)
{ {
return new DirectoriesPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew DirectoriesPrefs(parent);
} }

View File

@ -170,5 +170,6 @@ bool EffectsPrefs::Apply()
PrefsPanel *EffectsPrefsFactory::Create(wxWindow *parent) PrefsPanel *EffectsPrefsFactory::Create(wxWindow *parent)
{ {
return new EffectsPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew EffectsPrefs(parent);
} }

View File

@ -783,5 +783,6 @@ void ExtImportPrefsDropTarget::SetDataObject(wxDataObject* data)
PrefsPanel *ExtImportPrefsFactory::Create(wxWindow *parent) PrefsPanel *ExtImportPrefsFactory::Create(wxWindow *parent)
{ {
return new ExtImportPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew ExtImportPrefs(parent);
} }

View File

@ -178,5 +178,6 @@ bool GUIPrefs::Apply()
PrefsPanel *GUIPrefsFactory::Create(wxWindow *parent) PrefsPanel *GUIPrefsFactory::Create(wxWindow *parent)
{ {
return new GUIPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew GUIPrefs(parent);
} }

View File

@ -112,5 +112,6 @@ bool ImportExportPrefs::Apply()
PrefsPanel *ImportExportPrefsFactory::Create(wxWindow *parent) PrefsPanel *ImportExportPrefsFactory::Create(wxWindow *parent)
{ {
return new ImportExportPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew ImportExportPrefs(parent);
} }

View File

@ -230,7 +230,7 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(wxEXPAND, 1); S.StartHorizontalLay(wxEXPAND, 1);
{ {
if (!mView) { if (!mView) {
mView = new KeyView(this, CommandsListID); mView = safenew KeyView(this, CommandsListID);
mView->SetName(_("Bindings")); mView->SetName(_("Bindings"));
} }
S.Prop(true); S.Prop(true);
@ -1209,5 +1209,6 @@ void KeyConfigPrefs::Cancel()
PrefsPanel *KeyConfigPrefsFactory::Create(wxWindow *parent) PrefsPanel *KeyConfigPrefsFactory::Create(wxWindow *parent)
{ {
return new KeyConfigPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew KeyConfigPrefs(parent);
} }

View File

@ -241,5 +241,6 @@ bool LibraryPrefs::Apply()
PrefsPanel *LibraryPrefsFactory::Create(wxWindow *parent) PrefsPanel *LibraryPrefsFactory::Create(wxWindow *parent)
{ {
return new LibraryPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew LibraryPrefs(parent);
} }

View File

@ -286,7 +286,8 @@ bool MidiIOPrefs::Validate()
PrefsPanel *MidiIOPrefsFactory::Create(wxWindow *parent) PrefsPanel *MidiIOPrefsFactory::Create(wxWindow *parent)
{ {
return new MidiIOPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew MidiIOPrefs(parent);
} }
#endif #endif

View File

@ -163,7 +163,6 @@ void ModulePrefs::SetModuleStatus( wxString fname, int iStatus ){
PrefsPanel *ModulePrefsFactory::Create(wxWindow *parent) PrefsPanel *ModulePrefsFactory::Create(wxWindow *parent)
{ {
return new ModulePrefs(parent); wxASSERT(parent); // to justify safenew
return safenew ModulePrefs(parent);
} }

View File

@ -205,5 +205,6 @@ bool MousePrefs::Apply()
PrefsPanel *MousePrefsFactory::Create(wxWindow *parent) PrefsPanel *MousePrefsFactory::Create(wxWindow *parent)
{ {
return new MousePrefs(parent); wxASSERT(parent); // to justify safenew
return safenew MousePrefs(parent);
} }

View File

@ -125,5 +125,6 @@ bool PlaybackPrefs::Apply()
PrefsPanel *PlaybackPrefsFactory::Create(wxWindow *parent) PrefsPanel *PlaybackPrefsFactory::Create(wxWindow *parent)
{ {
return new PlaybackPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew PlaybackPrefs(parent);
} }

View File

@ -64,6 +64,7 @@ class PrefsPanel:public wxPanel
class PrefsPanelFactory class PrefsPanelFactory
{ {
public: public:
// Precondition: parent != NULL
virtual PrefsPanel *Create(wxWindow *parent) = 0; virtual PrefsPanel *Create(wxWindow *parent) = 0;
}; };

View File

@ -82,5 +82,6 @@ bool ProjectsPrefs::Apply()
PrefsPanel *ProjectsPrefsFactory::Create(wxWindow *parent) PrefsPanel *ProjectsPrefsFactory::Create(wxWindow *parent)
{ {
return new ProjectsPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew ProjectsPrefs(parent);
} }

View File

@ -230,5 +230,6 @@ bool QualityPrefs::Apply()
PrefsPanel *QualityPrefsFactory::Create(wxWindow *parent) PrefsPanel *QualityPrefsFactory::Create(wxWindow *parent)
{ {
return new QualityPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew QualityPrefs(parent);
} }

View File

@ -252,5 +252,6 @@ void RecordingPrefs::OnToggleCustomName(wxCommandEvent & Evt)
PrefsPanel *RecordingPrefsFactory::Create(wxWindow *parent) PrefsPanel *RecordingPrefsFactory::Create(wxWindow *parent)
{ {
return new RecordingPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew RecordingPrefs(parent);
} }

View File

@ -513,5 +513,6 @@ SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt)
PrefsPanel *SpectrumPrefsFactory::Create(wxWindow *parent) PrefsPanel *SpectrumPrefsFactory::Create(wxWindow *parent)
{ {
return new SpectrumPrefs(parent, mWt); wxASSERT(parent); // to justify safenew
return safenew SpectrumPrefs(parent, mWt);
} }

View File

@ -208,5 +208,6 @@ bool ThemePrefs::Apply()
PrefsPanel *ThemePrefsFactory::Create(wxWindow *parent) PrefsPanel *ThemePrefsFactory::Create(wxWindow *parent)
{ {
return new ThemePrefs(parent); wxASSERT(parent); // to justify safenew
return safenew ThemePrefs(parent);
} }

View File

@ -164,5 +164,6 @@ bool TracksPrefs::Apply()
PrefsPanel *TracksPrefsFactory::Create(wxWindow *parent) PrefsPanel *TracksPrefsFactory::Create(wxWindow *parent)
{ {
return new TracksPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew TracksPrefs(parent);
} }

View File

@ -86,5 +86,6 @@ bool WarningsPrefs::Apply()
PrefsPanel *WarningsPrefsFactory::Create(wxWindow *parent) PrefsPanel *WarningsPrefsFactory::Create(wxWindow *parent)
{ {
return new WarningsPrefs(parent); wxASSERT(parent); // to justify safenew
return safenew WarningsPrefs(parent);
} }

View File

@ -244,5 +244,6 @@ WaveformPrefsFactory::WaveformPrefsFactory(WaveTrack *wt)
PrefsPanel *WaveformPrefsFactory::Create(wxWindow *parent) PrefsPanel *WaveformPrefsFactory::Create(wxWindow *parent)
{ {
return new WaveformPrefs(parent, mWt); wxASSERT(parent); // to justify safenew
return safenew WaveformPrefs(parent, mWt);
} }

View File

@ -82,8 +82,6 @@ EditToolBar::EditToolBar()
EditToolBar::~EditToolBar() EditToolBar::~EditToolBar()
{ {
for (int i=0; i<ETBNumButtons; i++)
delete mButtons[i];
} }
void EditToolBar::Create(wxWindow * parent) void EditToolBar::Create(wxWindow * parent)

View File

@ -119,7 +119,7 @@ void MeterToolBar::Populate()
if( mWhichMeters & kWithRecordMeter ){ if( mWhichMeters & kWithRecordMeter ){
//JKC: Record on left, playback on right. Left to right flow //JKC: Record on left, playback on right. Left to right flow
//(maybe we should do it differently for Arabic language :-) ) //(maybe we should do it differently for Arabic language :-) )
mRecordMeter = new Meter( mProject, mRecordMeter = safenew Meter( mProject,
this, this,
wxID_ANY, wxID_ANY,
true, true,
@ -135,7 +135,7 @@ void MeterToolBar::Populate()
} }
if( mWhichMeters & kWithPlayMeter ){ if( mWhichMeters & kWithPlayMeter ){
mPlayMeter = new Meter( mProject, mPlayMeter = safenew Meter( mProject,
this, this,
wxID_ANY, wxID_ANY,
false, false,

View File

@ -84,7 +84,7 @@ void MixerToolBar::Populate()
wxID_ANY, wxID_ANY,
*mRecordBitmap), 0, wxALIGN_CENTER); *mRecordBitmap), 0, wxALIGN_CENTER);
mInputSlider = new ASlider(this, wxID_ANY, _("Recording Volume"), mInputSlider = safenew ASlider(this, wxID_ANY, _("Recording Volume"),
wxDefaultPosition, wxSize(130, 25)); wxDefaultPosition, wxSize(130, 25));
mInputSlider->SetScroll(0.1f, 2.0f); mInputSlider->SetScroll(0.1f, 2.0f);
mInputSlider->SetName(_("Slider Recording")); mInputSlider->SetName(_("Slider Recording"));
@ -97,7 +97,7 @@ void MixerToolBar::Populate()
wxID_ANY, wxID_ANY,
*mPlayBitmap), 0, wxALIGN_CENTER); *mPlayBitmap), 0, wxALIGN_CENTER);
mOutputSlider = new ASlider(this, wxID_ANY, _("Playback Volume"), mOutputSlider = safenew ASlider(this, wxID_ANY, _("Playback Volume"),
wxDefaultPosition, wxSize(130, 25)); wxDefaultPosition, wxSize(130, 25));
mOutputSlider->SetScroll(0.1f, 2.0f); mOutputSlider->SetScroll(0.1f, 2.0f);
mOutputSlider->SetName(_("Slider Playback")); mOutputSlider->SetName(_("Slider Playback"));

View File

@ -251,13 +251,13 @@ void SelectionBar::Populate()
NULL, NULL,
this); this);
mLeftTime = new NumericTextCtrl( mLeftTime = safenew NumericTextCtrl(
NumericConverter::TIME, this, OnLeftTimeID, formatName, 0.0, mRate); NumericConverter::TIME, this, OnLeftTimeID, formatName, 0.0, mRate);
mLeftTime->SetName(_("Selection Start:")); mLeftTime->SetName(_("Selection Start:"));
mLeftTime->EnableMenu(); mLeftTime->EnableMenu();
mainSizer->Add(mLeftTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); mainSizer->Add(mLeftTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
mRightTime = new NumericTextCtrl( mRightTime = safenew NumericTextCtrl(
NumericConverter::TIME, this, OnRightTimeID, formatName, 0.0, mRate); NumericConverter::TIME, this, OnRightTimeID, formatName, 0.0, mRate);
mRightTime->SetName(wxString(_("Selection ")) + (showSelectionLength ? mRightTime->SetName(wxString(_("Selection ")) + (showSelectionLength ?
_("Length") : _("Length") :
@ -270,7 +270,7 @@ void SelectionBar::Populate()
wxLI_VERTICAL), wxLI_VERTICAL),
0, wxRIGHT, 5); 0, wxRIGHT, 5);
mAudioTime = new NumericTextCtrl( mAudioTime = safenew NumericTextCtrl(
NumericConverter::TIME, this, wxID_ANY, formatName, 0.0, mRate); NumericConverter::TIME, this, wxID_ANY, formatName, 0.0, mRate);
mAudioTime->SetName(_("Audio Position:")); mAudioTime->SetName(_("Audio Position:"));
mAudioTime->EnableMenu(); mAudioTime->EnableMenu();

View File

@ -146,28 +146,28 @@ void SpectralSelectionBar::Populate()
wxBoxSizer *subSizer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *subSizer = new wxBoxSizer(wxHORIZONTAL);
mCenterCtrl = new NumericTextCtrl( mCenterCtrl = safenew NumericTextCtrl(
NumericConverter::FREQUENCY, this, OnCenterID, frequencyFormatName, 0.0); NumericConverter::FREQUENCY, this, OnCenterID, frequencyFormatName, 0.0);
mCenterCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); mCenterCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency);
mCenterCtrl->SetName(_("Center Frequency:")); mCenterCtrl->SetName(_("Center Frequency:"));
mCenterCtrl->EnableMenu(); mCenterCtrl->EnableMenu();
subSizer->Add(mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); subSizer->Add(mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
mWidthCtrl = new NumericTextCtrl( mWidthCtrl = safenew NumericTextCtrl(
NumericConverter::BANDWIDTH, this, OnWidthID, bandwidthFormatName, 0.0); NumericConverter::BANDWIDTH, this, OnWidthID, bandwidthFormatName, 0.0);
mWidthCtrl->SetInvalidValue(-1.0); mWidthCtrl->SetInvalidValue(-1.0);
mWidthCtrl->SetName(wxString(_("Bandwidth:"))); mWidthCtrl->SetName(wxString(_("Bandwidth:")));
mWidthCtrl->EnableMenu(); mWidthCtrl->EnableMenu();
subSizer->Add(mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); subSizer->Add(mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0);
mLowCtrl = new NumericTextCtrl( mLowCtrl = safenew NumericTextCtrl(
NumericConverter::FREQUENCY, this, OnLowID, frequencyFormatName, 0.0); NumericConverter::FREQUENCY, this, OnLowID, frequencyFormatName, 0.0);
mLowCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); mLowCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency);
mLowCtrl->SetName(_("Low Frequency:")); mLowCtrl->SetName(_("Low Frequency:"));
mLowCtrl->EnableMenu(); mLowCtrl->EnableMenu();
subSizer->Add(mLowCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); subSizer->Add(mLowCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
mHighCtrl = new NumericTextCtrl( mHighCtrl = safenew NumericTextCtrl(
NumericConverter::FREQUENCY, this, OnHighID, frequencyFormatName, 0.0); NumericConverter::FREQUENCY, this, OnHighID, frequencyFormatName, 0.0);
mHighCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); mHighCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency);
mHighCtrl->SetName(wxString(_("High Frequency:"))); mHighCtrl->SetName(wxString(_("High Frequency:")));

View File

@ -426,7 +426,7 @@ void ToolBar::ReCreateButtons()
wxBoxSizer *ms = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer *ms = new wxBoxSizer( wxHORIZONTAL );
// Create the grabber and add it to the main sizer // Create the grabber and add it to the main sizer
mGrabber = new Grabber( this, mType ); mGrabber = safenew Grabber( this, mType );
ms->Add( mGrabber, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxRIGHT, 1 ); ms->Add( mGrabber, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP | wxRIGHT, 1 );
// Use a box sizer for laying out controls // Use a box sizer for laying out controls
@ -443,7 +443,7 @@ void ToolBar::ReCreateButtons()
if( IsResizable() ) if( IsResizable() )
{ {
// Create the resizer and add it to the main sizer // Create the resizer and add it to the main sizer
mResizer = new ToolBarResizer( this ); mResizer = safenew ToolBarResizer( this );
ms->Add( mResizer, 0, wxEXPAND | wxALIGN_TOP | wxLEFT, 1 ); ms->Add( mResizer, 0, wxEXPAND | wxALIGN_TOP | wxLEFT, 1 );
mResizer->SetToolTip( _("Click and drag to resize toolbar") ); mResizer->SetToolTip( _("Click and drag to resize toolbar") );
} }

View File

@ -402,8 +402,8 @@ ToolManager::ToolManager( AudacityProject *parent )
this ); this );
// Create the top and bottom docks // Create the top and bottom docks
mTopDock = new ToolDock( this, mParent, TopDockID ); mTopDock = safenew ToolDock( this, mParent, TopDockID );
mBotDock = new ToolDock( this, mParent, BotDockID ); mBotDock = safenew ToolDock( this, mParent, BotDockID );
// Create all of the toolbars // Create all of the toolbars
mBars[ ToolsBarID ] = new ToolsToolBar(); mBars[ ToolsBarID ] = new ToolsToolBar();
@ -542,7 +542,7 @@ void ToolManager::Reset()
// Maybe construct a NEW floater // Maybe construct a NEW floater
// this happens if we have just been bounced out of a dock. // this happens if we have just been bounced out of a dock.
if( floater == NULL ) { if( floater == NULL ) {
floater = new ToolFrame( mParent, this, bar, wxPoint(-1,-1) ); floater = safenew ToolFrame( mParent, this, bar, wxPoint(-1,-1) );
bar->Reparent( floater ); bar->Reparent( floater );
} }
@ -710,7 +710,7 @@ void ToolManager::ReadConfig()
// Construct a NEW floater // Construct a NEW floater
ToolFrame *f = new ToolFrame( mParent, this, bar, wxPoint( x, y ) ); ToolFrame *f = safenew ToolFrame( mParent, this, bar, wxPoint( x, y ) );
// Set the width and height // Set the width and height
if( width[ ndx ] != -1 && height[ ndx ] != -1 ) if( width[ ndx ] != -1 && height[ ndx ] != -1 )

View File

@ -124,8 +124,6 @@ ToolsToolBar::ToolsToolBar()
ToolsToolBar::~ToolsToolBar() ToolsToolBar::~ToolsToolBar()
{ {
for (int i = 0; i < 5; i++)
delete mTool[i];
} }
void ToolsToolBar::RegenerateToolsTooltips() void ToolsToolBar::RegenerateToolsTooltips()

View File

@ -193,7 +193,7 @@ void TranscriptionToolBar::Populate()
//Add a slider that controls the speed of playback. //Add a slider that controls the speed of playback.
const int SliderWidth=100; const int SliderWidth=100;
mPlaySpeedSlider = new ASlider(this, mPlaySpeedSlider = safenew ASlider(this,
TTB_PlaySpeedSlider, TTB_PlaySpeedSlider,
_("Playback Speed"), _("Playback Speed"),
wxDefaultPosition, wxDefaultPosition,
@ -236,7 +236,7 @@ void TranscriptionToolBar::Populate()
AddButton(bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate, AddButton(bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate,
TRANSLATABLE("Calibrate voicekey")); TRANSLATABLE("Calibrate voicekey"));
mSensitivitySlider = new ASlider(this, mSensitivitySlider = safenew ASlider(this,
TTB_SensitivitySlider, TTB_SensitivitySlider,
TRANSLATABLE("Adjust Sensitivity"), TRANSLATABLE("Adjust Sensitivity"),
wxDefaultPosition, wxDefaultPosition,

View File

@ -202,7 +202,7 @@ SliderDialog::SliderDialog(wxWindow * parent, wxWindowID id,
15); 15);
mTextCtrl->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); mTextCtrl->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
mSlider = new ASlider(this, mSlider = safenew ASlider(this,
wxID_ANY, wxID_ANY,
title, title,
wxDefaultPosition, wxDefaultPosition,

View File

@ -145,7 +145,7 @@ ExpandingToolBar::ExpandingToolBar(wxWindow* parent,
ToolBarArea *toolBarParent = ToolBarArea *toolBarParent =
dynamic_cast<ToolBarArea *>(GetParent()); dynamic_cast<ToolBarArea *>(GetParent());
if (toolBarParent) if (toolBarParent)
mGrabber = new ToolBarGrabber(this, -1, this); mGrabber = safenew ToolBarGrabber(this, -1, this);
/// \todo check whether this is a memory leak (and check similar code) /// \todo check whether this is a memory leak (and check similar code)
wxImage hbar = theTheme.Image(bmpToolBarToggle); wxImage hbar = theTheme.Image(bmpToolBarToggle);
@ -542,7 +542,7 @@ void ExpandingToolBar::StartMoving()
ImageRoll tgtImageRoll = ImageRoll(ImageRoll::VerticalRoll, ImageRoll tgtImageRoll = ImageRoll(ImageRoll::VerticalRoll,
tgtImage, tgtImage,
magicColor); magicColor);
mTargetPanel = new ImageRollPanel(mAreaParent, -1, tgtImageRoll, mTargetPanel = safenew ImageRollPanel(mAreaParent, -1, tgtImageRoll,
wxDefaultPosition, wxDefaultPosition,
wxDefaultSize, wxDefaultSize,
wxTRANSPARENT_WINDOW); wxTRANSPARENT_WINDOW);
@ -622,7 +622,7 @@ void ExpandingToolBar::FinishMoving()
if (!mAreaParent || !mSavedArrangement) if (!mAreaParent || !mSavedArrangement)
return; return;
delete mTargetPanel; // DELETE mTargetPanel; // I think this is not needed, but unreachable anyway -- PRL
mAreaParent->SetCapturedChild(NULL); mAreaParent->SetCapturedChild(NULL);

View File

@ -44,7 +44,8 @@ TimeEditor::~TimeEditor()
void TimeEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler) void TimeEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler)
{ {
m_control = new NumericTextCtrl(NumericConverter::TIME, parent, wxASSERT(parent); // to justify safenew
m_control = safenew NumericTextCtrl(NumericConverter::TIME, parent,
wxID_ANY, wxID_ANY,
mFormat, mFormat,
mOld, mOld,

View File

@ -45,6 +45,7 @@ class TimeEditor:public wxGridCellEditor
~TimeEditor(); ~TimeEditor();
// Precondition: parent != NULL
void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler); void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler);
bool IsAcceptedKey(wxKeyEvent &event); bool IsAcceptedKey(wxKeyEvent &event);