From df6a7c5464155d2fb7594e370353f7fbb48e3c0b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 14 Feb 2016 02:54:25 -0500 Subject: [PATCH] More uses of safenew for classes we derive from wxWindow classes... ... Also removed some unnecessary deletes of widgets that are managed by parent windows --- src/FreqWindow.cpp | 8 ++++---- src/Lyrics.cpp | 2 +- src/LyricsWindow.cpp | 2 +- src/Menus.cpp | 4 ++-- src/MixerBoard.cpp | 18 +++++++++--------- src/Project.cpp | 6 +++--- src/ShuttleGui.cpp | 4 ++-- src/TimeDialog.cpp | 2 +- src/TimerRecordDialog.cpp | 6 +++--- src/TrackPanel.cpp | 3 ++- src/TrackPanel.h | 1 + src/effects/AutoDuck.cpp | 2 +- src/effects/ChangeSpeed.cpp | 4 ++-- src/effects/Compressor.cpp | 2 +- src/effects/Contrast.cpp | 8 ++++---- src/effects/DtmfGen.cpp | 2 +- src/effects/Effect.cpp | 2 +- src/effects/EffectManager.cpp | 5 ++++- src/effects/Equalization.cpp | 8 ++++---- src/effects/Noise.cpp | 2 +- src/effects/ScienFilter.cpp | 8 ++++---- src/effects/Silence.cpp | 2 +- src/effects/ToneGen.cpp | 2 +- src/effects/VST/VSTEffect.cpp | 2 +- src/effects/ladspa/LadspaEffect.cpp | 4 ++-- src/effects/lv2/LV2Effect.cpp | 4 ++-- src/export/Export.cpp | 2 +- src/export/Export.h | 5 +++-- src/export/ExportCL.cpp | 3 ++- src/export/ExportFFmpeg.cpp | 11 ++++++----- src/export/ExportFLAC.cpp | 3 ++- src/export/ExportMP2.cpp | 3 ++- src/export/ExportMP3.cpp | 3 ++- src/export/ExportOGG.cpp | 3 ++- src/export/ExportPCM.cpp | 3 ++- src/prefs/BatchPrefs.cpp | 3 ++- src/prefs/DevicePrefs.cpp | 3 ++- src/prefs/DirectoriesPrefs.cpp | 3 ++- src/prefs/EffectsPrefs.cpp | 3 ++- src/prefs/ExtImportPrefs.cpp | 3 ++- src/prefs/GUIPrefs.cpp | 3 ++- src/prefs/ImportExportPrefs.cpp | 3 ++- src/prefs/KeyConfigPrefs.cpp | 5 +++-- src/prefs/LibraryPrefs.cpp | 3 ++- src/prefs/MidiIOPrefs.cpp | 3 ++- src/prefs/ModulePrefs.cpp | 5 ++--- src/prefs/MousePrefs.cpp | 3 ++- src/prefs/PlaybackPrefs.cpp | 3 ++- src/prefs/PrefsPanel.h | 1 + src/prefs/ProjectsPrefs.cpp | 3 ++- src/prefs/QualityPrefs.cpp | 3 ++- src/prefs/RecordingPrefs.cpp | 3 ++- src/prefs/SpectrumPrefs.cpp | 3 ++- src/prefs/ThemePrefs.cpp | 3 ++- src/prefs/TracksPrefs.cpp | 3 ++- src/prefs/WarningsPrefs.cpp | 3 ++- src/prefs/WaveformPrefs.cpp | 3 ++- src/toolbars/EditToolBar.cpp | 2 -- src/toolbars/MeterToolBar.cpp | 4 ++-- src/toolbars/MixerToolBar.cpp | 4 ++-- src/toolbars/SelectionBar.cpp | 6 +++--- src/toolbars/SpectralSelectionBar.cpp | 8 ++++---- src/toolbars/ToolBar.cpp | 4 ++-- src/toolbars/ToolManager.cpp | 8 ++++---- src/toolbars/ToolsToolBar.cpp | 2 -- src/toolbars/TranscriptionToolBar.cpp | 4 ++-- src/widgets/ASlider.cpp | 2 +- src/widgets/ExpandingToolBar.cpp | 6 +++--- src/widgets/Grid.cpp | 3 ++- src/widgets/Grid.h | 1 + 70 files changed, 151 insertions(+), 120 deletions(-) diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index d7fb23ae7..c67abb699 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -277,7 +277,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, 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.SetOrientation(wxVERTICAL); vRuler->ruler.SetRange(0.0, -dBRange); @@ -295,7 +295,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, } S.EndVerticalLay(); - mFreqPlot = new FreqPlot(this); + mFreqPlot = safenew FreqPlot(this); mFreqPlot->SetMinSize(wxSize(wxDefaultCoord, FREQ_WINDOW_HEIGHT)); S.Prop(1); S.AddWindow(mFreqPlot, wxEXPAND); @@ -344,7 +344,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, 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.SetOrientation(wxHORIZONTAL); hRuler->ruler.SetLog(true); @@ -477,7 +477,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, S.AddSpace(5); - mProgress = new FreqGauge(this); //, wxID_ANY, wxST_SIZEGRIP); + mProgress = safenew FreqGauge(this); //, wxID_ANY, wxST_SIZEGRIP); S.AddWindow(mProgress, wxEXPAND); // Log-frequency axis works for spectrum plots only. diff --git a/src/Lyrics.cpp b/src/Lyrics.cpp index bd1e19840..90ae34887 100644 --- a/src/Lyrics.cpp +++ b/src/Lyrics.cpp @@ -93,7 +93,7 @@ Lyrics::Lyrics(wxWindow* parent, wxWindowID id, this->SetBackgroundColour(*wxWHITE); mHighlightTextCtrl = - new HighlightTextCtrl(this, -1, // wxWindow* parent, wxWindowID id, + safenew HighlightTextCtrl(this, -1, // wxWindow* parent, wxWindowID id, wxT(""), // const wxString& value = wxT(""), wxPoint(0, 0), // const wxPoint& pos = wxDefaultPosition, size); // const wxSize& size = wxDefaultSize diff --git a/src/LyricsWindow.cpp b/src/LyricsWindow.cpp index b2c82937b..47c97ff32 100644 --- a/src/LyricsWindow.cpp +++ b/src/LyricsWindow.cpp @@ -113,7 +113,7 @@ LyricsWindow::LyricsWindow(AudacityProject *parent): // //pToolBar->Realize(); - mLyricsPanel = new Lyrics(this, -1, panelPos, panelSize); + mLyricsPanel = safenew Lyrics(this, -1, panelPos, panelSize); //vvv Highlight style is broken in ported version. //switch (mLyricsPanel->GetLyricsStyle()) diff --git a/src/Menus.cpp b/src/Menus.cpp index 5650fb849..228f24b4d 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -5255,7 +5255,7 @@ void AudacityProject::OnHistory() void AudacityProject::OnKaraoke() { if (!mLyricsWindow) - mLyricsWindow = new LyricsWindow(this); + mLyricsWindow = safenew LyricsWindow(this); mLyricsWindow->Show(); UpdateLyrics(); mLyricsWindow->Raise(); @@ -5265,7 +5265,7 @@ void AudacityProject::OnMixerBoard() { if (!mMixerBoardFrame) { - mMixerBoardFrame = new MixerBoardFrame(this); + mMixerBoardFrame = safenew MixerBoardFrame(this); mMixerBoard = mMixerBoardFrame->mMixerBoard; } mMixerBoardFrame->Show(); diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 6e84038cd..3c9409701 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -209,7 +209,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, #ifdef EXPERIMENTAL_MIDI_OUT if (mNoteTrack) { mSlider_Gain = - new MixerTrackSlider( + safenew MixerTrackSlider( this, ID_SLIDER_GAIN, /* i18n-hint: title of the MIDI Velocity slider */ _("Velocity"), @@ -218,7 +218,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, } else #endif mSlider_Gain = - new MixerTrackSlider( + safenew MixerTrackSlider( this, ID_SLIDER_GAIN, /* i18n-hint: title of the Gain slider, used to adjust the volume */ _("Gain"), @@ -258,7 +258,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, ctrlSize.x--; mSlider_Pan = - new MixerTrackSlider( + safenew MixerTrackSlider( this, ID_SLIDER_PAN, /* i18n-hint: Title of the Pan slider, used to move the sound left or right */ _("Pan"), @@ -271,7 +271,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, ctrlPos.y += PAN_HEIGHT + kDoubleInset; ctrlSize.Set(mMixerBoard->mMuteSoloWidth, MUTE_SOLO_HEIGHT); mToggleButton_Mute = - new AButton(this, ID_TOGGLEBUTTON_MUTE, + safenew AButton(this, ID_TOGGLEBUTTON_MUTE, ctrlPos, ctrlSize, *(mMixerBoard->mImageMuteUp), *(mMixerBoard->mImageMuteOver), *(mMixerBoard->mImageMuteDown), *(mMixerBoard->mImageMuteDisabled), @@ -285,7 +285,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, ctrlPos.y += MUTE_SOLO_HEIGHT; mToggleButton_Solo = - new AButton(this, ID_TOGGLEBUTTON_SOLO, + safenew AButton(this, ID_TOGGLEBUTTON_SOLO, ctrlPos, ctrlSize, *(mMixerBoard->mImageSoloUp), *(mMixerBoard->mImageSoloOver), *(mMixerBoard->mImageSoloDown), *(mMixerBoard->mImageSoloDisabled), @@ -308,7 +308,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, if (mLeftTrack) { #endif mMeter = - new Meter(GetActiveProject(), // AudacityProject* project, + safenew Meter(GetActiveProject(), // AudacityProject* project, this, -1, // wxWindow* parent, wxWindowID id, false, // bool isInput ctrlPos, ctrlSize, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, @@ -984,7 +984,7 @@ MixerBoard::MixerBoard(AudacityProject* pProject, mProject = pProject; mScrolledWindow = - new MixerBoardScrolledWindow( + safenew MixerBoardScrolledWindow( pProject, // AudacityProject* project, this, -1, // wxWindow* parent, wxWindowID id = -1, this->GetClientAreaOrigin(), // const wxPoint& pos = wxDefaultPosition, @@ -1109,7 +1109,7 @@ void MixerBoard::UpdateTrackClusters() kInset); wxSize clusterSize(kMixerTrackClusterWidth, nClusterHeight); pMixerTrackCluster = - new MixerTrackCluster(mScrolledWindow, this, mProject, + safenew MixerTrackCluster(mScrolledWindow, this, mProject, (WaveTrack*)pLeftTrack, (WaveTrack*)pRightTrack, clusterPos, clusterSize); if (pMixerTrackCluster) @@ -1758,7 +1758,7 @@ MixerBoardFrame::MixerBoardFrame(AudacityProject* parent) // wxDEFAULT_FRAME_STYLE | wxFRAME_FLOAT_ON_PARENT) 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); diff --git a/src/Project.cpp b/src/Project.cpp index 4393bf2ca..881caebcf 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -897,7 +897,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, // // Create the horizontal ruler // - mRuler = new AdornedRulerPanel( this, + mRuler = safenew AdornedRulerPanel( this, wxID_ANY, wxDefaultPosition, 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 // creating the scrollbars after the TrackPanel, we resolve // several focus problems. - mHsbar = new ScrollBar(pPage, HSBarID, wxSB_HORIZONTAL); - mVsbar = new ScrollBar(pPage, VSBarID, wxSB_VERTICAL); + mHsbar = safenew ScrollBar(pPage, HSBarID, wxSB_HORIZONTAL); + mVsbar = safenew ScrollBar(pPage, VSBarID, wxSB_VERTICAL); // LLL: When Audacity starts or becomes active after returning from // another application, the first window that can accept focus diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index ba36fd569..98f9a36cd 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -2077,8 +2077,8 @@ RulerPanel * ShuttleGui::AddRulerVertical(float low, float hi, const wxString & // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), RulerPanel); RulerPanel * pRulerPanel; miProp=0; - mpWind = pRulerPanel = new RulerPanel( - mpParent, + mpWind = pRulerPanel = safenew RulerPanel( + GetParent(), miId, wxDefaultPosition, wxDefaultSize diff --git a/src/TimeDialog.cpp b/src/TimeDialog.cpp index cd73acfb7..1298fb970 100644 --- a/src/TimeDialog.cpp +++ b/src/TimeDialog.cpp @@ -54,7 +54,7 @@ void TimeDialog::PopulateOrExchange(ShuttleGui &S) { S.StartStatic(mPrompt, true); { - mTimeCtrl = new + mTimeCtrl = safenew NumericTextCtrl( NumericConverter::TIME, this, wxID_ANY, diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index 6145bc520..96790744f 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -364,7 +364,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) m_pDatePickerCtrl_Start->SetRange(wxDateTime::Today(), wxInvalidDateTime); // No backdating. S.AddWindow(m_pDatePickerCtrl_Start); - m_pTimeTextCtrl_Start = new NumericTextCtrl( + m_pTimeTextCtrl_Start = safenew NumericTextCtrl( NumericConverter::TIME, this, ID_TIMETEXT_START); m_pTimeTextCtrl_Start->SetName(_("Start Time")); m_pTimeTextCtrl_Start->SetFormatString(strFormat); @@ -386,7 +386,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) m_pDatePickerCtrl_End->SetName(_("End Date")); S.AddWindow(m_pDatePickerCtrl_End); - m_pTimeTextCtrl_End = new NumericTextCtrl( + m_pTimeTextCtrl_End = safenew NumericTextCtrl( NumericConverter::TIME, this, ID_TIMETEXT_END); m_pTimeTextCtrl_End->SetName(_("End Time")); m_pTimeTextCtrl_End->SetFormatString(strFormat); @@ -407,7 +407,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) * seconds. */ 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); m_pTimeTextCtrl_Duration->SetName(_("Duration")); m_pTimeTextCtrl_Duration->SetFormatString(strFormat1); diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index fdbe9c225..d99808622 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -10065,7 +10065,8 @@ static TrackPanel * TrackPanelFactory(wxWindow * parent, TrackPanelListener * listener, AdornedRulerPanel * ruler) { - return new TrackPanel( + wxASSERT(parent); // to justify safenew + return safenew TrackPanel( parent, id, pos, diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 825e4692b..df8547d3d 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -515,6 +515,7 @@ public: TrackPanelListener * GetListener(){ return mListener;} AdornedRulerPanel * GetRuler(){ return mRuler;} // JKC and here is a factory function which just does 'NEW' in standard Audacity. + // Precondition: parent != NULL static TrackPanel *(*FactoryFunction)(wxWindow * parent, wxWindowID id, const wxPoint & pos, diff --git a/src/effects/AutoDuck.cpp b/src/effects/AutoDuck.cpp index 5f3db54ff..0d73d29ca 100644 --- a/src/effects/AutoDuck.cpp +++ b/src/effects/AutoDuck.cpp @@ -424,7 +424,7 @@ void EffectAutoDuck::PopulateOrExchange(ShuttleGui & S) { S.AddSpace(0, 5); - mPanel = new EffectAutoDuckPanel(S.GetParent(), this); + mPanel = safenew EffectAutoDuckPanel(S.GetParent(), this); S.AddWindow(mPanel); S.AddSpace(0, 5); diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index bfb06b813..2fdcb68b4 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -362,7 +362,7 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S) { S.AddPrompt(_("Current Length:")); - mpFromLengthCtrl = new + mpFromLengthCtrl = safenew NumericTextCtrl(NumericConverter::TIME, S.GetParent(), wxID_ANY, @@ -378,7 +378,7 @@ void EffectChangeSpeed::PopulateOrExchange(ShuttleGui & S) S.AddPrompt(_("New Length:")); - mpToLengthCtrl = new + mpToLengthCtrl = safenew NumericTextCtrl(NumericConverter::TIME, S.GetParent(), ID_ToLength, diff --git a/src/effects/Compressor.cpp b/src/effects/Compressor.cpp index f0fd831e8..07538d044 100644 --- a/src/effects/Compressor.cpp +++ b/src/effects/Compressor.cpp @@ -205,7 +205,7 @@ void EffectCompressor::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(wxEXPAND, true); { S.SetBorder(10); - mPanel = new EffectCompressorPanel(S.GetParent(), + mPanel = safenew EffectCompressorPanel(S.GetParent(), mThresholdDB, mNoiseFloorDB, mRatio); diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index d5576531c..631fd07af 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -226,7 +226,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, S.AddFixedText(_("&Foreground:"), false); if (S.GetMode() == eIsCreating) { - mForegroundStartT = new + mForegroundStartT = safenew NumericTextCtrl(NumericConverter::TIME, this, ID_FOREGROUNDSTART_T, _("hh:mm:ss + hundredths"), @@ -242,7 +242,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, if (S.GetMode() == eIsCreating) { - mForegroundEndT = new + mForegroundEndT = safenew NumericTextCtrl(NumericConverter::TIME, this, ID_FOREGROUNDEND_T, _("hh:mm:ss + hundredths"), @@ -264,7 +264,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, S.AddFixedText(_("&Background:")); if (S.GetMode() == eIsCreating) { - mBackgroundStartT = new + mBackgroundStartT = safenew NumericTextCtrl(NumericConverter::TIME, this, ID_BACKGROUNDSTART_T, _("hh:mm:ss + hundredths"), @@ -280,7 +280,7 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, if (S.GetMode() == eIsCreating) { - mBackgroundEndT = new + mBackgroundEndT = safenew NumericTextCtrl(NumericConverter::TIME, this, ID_BACKGROUNDEND_T, _("hh:mm:ss + hundredths"), diff --git a/src/effects/DtmfGen.cpp b/src/effects/DtmfGen.cpp index 893126281..3a55d4d76 100644 --- a/src/effects/DtmfGen.cpp +++ b/src/effects/DtmfGen.cpp @@ -312,7 +312,7 @@ void EffectDtmf::PopulateOrExchange(ShuttleGui & S) S.Id(ID_Amplitude).AddTextBox(_("Amplitude (0-1):"), wxT(""), 10)->SetValidator(vldAmp); S.AddPrompt(_("Duration:")); - mDtmfDurationT = new + mDtmfDurationT = safenew NumericTextCtrl(NumericConverter::TIME, S.GetParent(), ID_Duration, diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index d6b0670ae..264d6cef5 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -2884,7 +2884,7 @@ bool EffectUIHost::Initialize() wxBoxSizer *vs = new wxBoxSizer(wxVERTICAL); 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 w->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3), diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp index b25e9496e..3ae6894f0 100644 --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -342,7 +342,10 @@ EffectRack *EffectManager::GetRack() { 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(); } diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index d8c5ac83d..1a74652a0 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -599,7 +599,7 @@ bool EffectEqualization::CloseUI() void EffectEqualization::PopulateOrExchange(ShuttleGui & S) { - wxWindow *parent = S.GetParent(); + wxWindow *const parent = S.GetParent(); LoadCurves(); @@ -634,7 +634,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) // ------------------------------------------------------------------- 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.SetOrientation(wxVERTICAL); mdBRuler->ruler.SetRange(60.0, -120.0); @@ -653,7 +653,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) } S.EndVerticalLay(); - mPanel = new EqualizationPanel(this, parent); + mPanel = safenew EqualizationPanel(this, parent); S.Prop(1); S.AddWindow(mPanel, wxEXPAND | wxALIGN_LEFT | wxALIGN_TOP); S.SetSizeHints(wxDefaultCoord, wxDefaultCoord); @@ -687,7 +687,7 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) // Column 1 is empty 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.SetOrientation(wxHORIZONTAL); mFreqRuler->ruler.SetLog(true); diff --git a/src/effects/Noise.cpp b/src/effects/Noise.cpp index 398358035..6c7fab735 100644 --- a/src/effects/Noise.cpp +++ b/src/effects/Noise.cpp @@ -225,7 +225,7 @@ void EffectNoise::PopulateOrExchange(ShuttleGui & S) S.AddTextBox(_("Amplitude (0-1):"), wxT(""), 12)->SetValidator(vldAmp); S.AddPrompt(_("Duration:")); - mNoiseDurationT = new + mNoiseDurationT = safenew NumericTextCtrl(NumericConverter::TIME, S.GetParent(), wxID_ANY, diff --git a/src/effects/ScienFilter.cpp b/src/effects/ScienFilter.cpp index 5569f995c..a1f5e3976 100644 --- a/src/effects/ScienFilter.cpp +++ b/src/effects/ScienFilter.cpp @@ -363,7 +363,7 @@ bool EffectScienFilter::Init() void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) { - wxWindow *parent = S.GetParent(); + wxWindow *const parent = S.GetParent(); S.AddSpace(5); S.SetSizerProportion(1); @@ -378,7 +378,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) 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.SetOrientation(wxVERTICAL); mdBRuler->ruler.SetRange(30.0, -120.0); @@ -397,7 +397,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) } S.EndVerticalLay(); - mPanel = new EffectScienFilterPanel(this, parent); + mPanel = safenew EffectScienFilterPanel(this, parent); mPanel->SetFreqRange(mLoFreq, mNyquist); S.SetBorder(5); @@ -431,7 +431,7 @@ void EffectScienFilter::PopulateOrExchange(ShuttleGui & S) 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.SetOrientation(wxHORIZONTAL); mfreqRuler->ruler.SetLog(true); diff --git a/src/effects/Silence.cpp b/src/effects/Silence.cpp index 2894ef1e7..1085db9d2 100644 --- a/src/effects/Silence.cpp +++ b/src/effects/Silence.cpp @@ -58,7 +58,7 @@ void EffectSilence::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(); { S.AddPrompt(_("Duration:")); - mDurationT = new + mDurationT = safenew NumericTextCtrl(NumericConverter::TIME, S.GetParent(), wxID_ANY, diff --git a/src/effects/ToneGen.cpp b/src/effects/ToneGen.cpp index fef31fafb..12c92db3e 100644 --- a/src/effects/ToneGen.cpp +++ b/src/effects/ToneGen.cpp @@ -395,7 +395,7 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) } S.AddPrompt(_("Duration:")); - mToneDurationT = new + mToneDurationT = safenew NumericTextCtrl(NumericConverter::TIME, S.GetParent(), wxID_ANY, diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 6164f2fef..23589691b 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -2884,7 +2884,7 @@ void VSTEffect::BuildPlain() { wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - mDuration = new + mDuration = safenew NumericTextCtrl(NumericConverter::TIME, scroller, ID_Duration, diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 282d2463a..5ab9a4d6c 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -1196,7 +1196,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) { item = safenew wxStaticText(w, 0, _("Duration:")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - mDuration = new + mDuration = safenew NumericTextCtrl(NumericConverter::TIME, w, ID_Duration, @@ -1431,7 +1431,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) upper = floorf(upper * 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); gridSizer->Add(mMeters[p], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5); } diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index bef908fae..ede34c53b 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -1604,7 +1604,7 @@ bool LV2Effect::BuildPlain() wxWindow *item = safenew wxStaticText(w, 0, _("&Duration:")); sizer->Add(item, 0, wxALIGN_CENTER | wxALL, 5); - mDuration = new + mDuration = safenew NumericTextCtrl(NumericConverter::TIME, w, ID_Duration, @@ -1707,7 +1707,7 @@ bool LV2Effect::BuildPlain() { 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(1, 1, 0); } diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 87b810a27..445445831 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -1216,7 +1216,7 @@ ExportMixerDialog::ExportMixerDialog( TrackList *tracks, bool selectedOnly, 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 ) ); mixerPanel->SetName(_("Mixer Panel")); vertSizer->Add( mixerPanel, 1, wxEXPAND | wxALIGN_CENTRE | wxALL, 5 ); diff --git a/src/export/Export.h b/src/export/Export.h index 65ea85f7d..38cfa0340 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -83,8 +83,9 @@ public: virtual bool IsExtension(const wxString & ext, int index); 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); diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index 524278429..8fdb4641a 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -536,7 +536,8 @@ int ExportCL::Export(AudacityProject *project, 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() diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index 910309d48..351772d0e 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -983,27 +983,28 @@ int ExportFFmpeg::AskResample(int bitrate, int rate, int lowrate, int highrate, wxWindow *ExportFFmpeg::OptionsCreate(wxWindow *parent, int format) { + wxASSERT(parent); // to justify safenew // subformat index may not correspond directly to fmts[] index, convert it mSubFormat = AdjustFormatIndex(format); if (mSubFormat == FMT_M4A) { - return new ExportFFmpegAACOptions(parent, format); + return safenew ExportFFmpegAACOptions(parent, format); } else if (mSubFormat == FMT_AC3) { - return new ExportFFmpegAC3Options(parent, format); + return safenew ExportFFmpegAC3Options(parent, format); } else if (mSubFormat == FMT_AMRNB) { - return new ExportFFmpegAMRNBOptions(parent, format); + return safenew ExportFFmpegAMRNBOptions(parent, format); } else if (mSubFormat == FMT_WMA2) { - return new ExportFFmpegWMAOptions(parent, format); + return safenew ExportFFmpegWMAOptions(parent, format); } else if (mSubFormat == FMT_OTHER) { - return new ExportFFmpegCustomOptions(parent, format); + return safenew ExportFFmpegCustomOptions(parent, format); } return ExportPlugin::OptionsCreate(parent, format); diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index ec9b49882..cbba97e13 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -370,7 +370,8 @@ int ExportFLAC::Export(AudacityProject *project, 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 diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp index 54ecd2db7..d7339a2ff 100644 --- a/src/export/ExportMP2.cpp +++ b/src/export/ExportMP2.cpp @@ -334,7 +334,8 @@ int ExportMP2::Export(AudacityProject *project, 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 diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index c0eb9f720..53dd06d20 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -1869,7 +1869,8 @@ int ExportMP3::Export(AudacityProject *project, 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) diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp index 15369b27a..09d7643af 100644 --- a/src/export/ExportOGG.cpp +++ b/src/export/ExportOGG.cpp @@ -337,7 +337,8 @@ int ExportOGG::Export(AudacityProject *project, 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) diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index b8a648e19..2e40daaea 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -877,10 +877,11 @@ void ExportPCM::AddID3Chunk(wxString fName, Tags *tags, int sf_format) wxWindow *ExportPCM::OptionsCreate(wxWindow *parent, int format) { + wxASSERT(parent); // to justify safenew // default, full user control if (format < 0 || format >= WXSIZEOF(kFormats)) { - return new ExportPCMOptions(parent, format); + return safenew ExportPCMOptions(parent, format); } return ExportPlugin::OptionsCreate(parent, format); diff --git a/src/prefs/BatchPrefs.cpp b/src/prefs/BatchPrefs.cpp index 58454628c..f8460f1ba 100644 --- a/src/prefs/BatchPrefs.cpp +++ b/src/prefs/BatchPrefs.cpp @@ -84,5 +84,6 @@ BatchPrefs::~BatchPrefs() PrefsPanel *BatchPrefsFactory::Create(wxWindow *parent) { - return new BatchPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew BatchPrefs(parent); } diff --git a/src/prefs/DevicePrefs.cpp b/src/prefs/DevicePrefs.cpp index 3189ad7ad..37532d677 100644 --- a/src/prefs/DevicePrefs.cpp +++ b/src/prefs/DevicePrefs.cpp @@ -374,5 +374,6 @@ bool DevicePrefs::Apply() PrefsPanel *DevicePrefsFactory::Create(wxWindow *parent) { - return new DevicePrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew DevicePrefs(parent); } diff --git a/src/prefs/DirectoriesPrefs.cpp b/src/prefs/DirectoriesPrefs.cpp index 0f4e8b273..4e82e3161 100644 --- a/src/prefs/DirectoriesPrefs.cpp +++ b/src/prefs/DirectoriesPrefs.cpp @@ -266,5 +266,6 @@ bool DirectoriesPrefs::Apply() PrefsPanel *DirectoriesPrefsFactory::Create(wxWindow *parent) { - return new DirectoriesPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew DirectoriesPrefs(parent); } diff --git a/src/prefs/EffectsPrefs.cpp b/src/prefs/EffectsPrefs.cpp index 60e2dbad1..d2b3bbcbc 100644 --- a/src/prefs/EffectsPrefs.cpp +++ b/src/prefs/EffectsPrefs.cpp @@ -170,5 +170,6 @@ bool EffectsPrefs::Apply() PrefsPanel *EffectsPrefsFactory::Create(wxWindow *parent) { - return new EffectsPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew EffectsPrefs(parent); } diff --git a/src/prefs/ExtImportPrefs.cpp b/src/prefs/ExtImportPrefs.cpp index 26c1b6593..87bf1ebb0 100644 --- a/src/prefs/ExtImportPrefs.cpp +++ b/src/prefs/ExtImportPrefs.cpp @@ -783,5 +783,6 @@ void ExtImportPrefsDropTarget::SetDataObject(wxDataObject* data) PrefsPanel *ExtImportPrefsFactory::Create(wxWindow *parent) { - return new ExtImportPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew ExtImportPrefs(parent); } diff --git a/src/prefs/GUIPrefs.cpp b/src/prefs/GUIPrefs.cpp index b0e4656a0..e0313b3db 100644 --- a/src/prefs/GUIPrefs.cpp +++ b/src/prefs/GUIPrefs.cpp @@ -178,5 +178,6 @@ bool GUIPrefs::Apply() PrefsPanel *GUIPrefsFactory::Create(wxWindow *parent) { - return new GUIPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew GUIPrefs(parent); } diff --git a/src/prefs/ImportExportPrefs.cpp b/src/prefs/ImportExportPrefs.cpp index 924171454..01a5e0d14 100644 --- a/src/prefs/ImportExportPrefs.cpp +++ b/src/prefs/ImportExportPrefs.cpp @@ -112,5 +112,6 @@ bool ImportExportPrefs::Apply() PrefsPanel *ImportExportPrefsFactory::Create(wxWindow *parent) { - return new ImportExportPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew ImportExportPrefs(parent); } diff --git a/src/prefs/KeyConfigPrefs.cpp b/src/prefs/KeyConfigPrefs.cpp index e6524f62d..e9b147cb9 100644 --- a/src/prefs/KeyConfigPrefs.cpp +++ b/src/prefs/KeyConfigPrefs.cpp @@ -230,7 +230,7 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(wxEXPAND, 1); { if (!mView) { - mView = new KeyView(this, CommandsListID); + mView = safenew KeyView(this, CommandsListID); mView->SetName(_("Bindings")); } S.Prop(true); @@ -1209,5 +1209,6 @@ void KeyConfigPrefs::Cancel() PrefsPanel *KeyConfigPrefsFactory::Create(wxWindow *parent) { - return new KeyConfigPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew KeyConfigPrefs(parent); } diff --git a/src/prefs/LibraryPrefs.cpp b/src/prefs/LibraryPrefs.cpp index e2a0dafe5..ab1d60c0e 100644 --- a/src/prefs/LibraryPrefs.cpp +++ b/src/prefs/LibraryPrefs.cpp @@ -241,5 +241,6 @@ bool LibraryPrefs::Apply() PrefsPanel *LibraryPrefsFactory::Create(wxWindow *parent) { - return new LibraryPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew LibraryPrefs(parent); } diff --git a/src/prefs/MidiIOPrefs.cpp b/src/prefs/MidiIOPrefs.cpp index 382876e1b..b8a0c816f 100644 --- a/src/prefs/MidiIOPrefs.cpp +++ b/src/prefs/MidiIOPrefs.cpp @@ -286,7 +286,8 @@ bool MidiIOPrefs::Validate() PrefsPanel *MidiIOPrefsFactory::Create(wxWindow *parent) { - return new MidiIOPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew MidiIOPrefs(parent); } #endif diff --git a/src/prefs/ModulePrefs.cpp b/src/prefs/ModulePrefs.cpp index b6afc548d..ddd8f69cd 100644 --- a/src/prefs/ModulePrefs.cpp +++ b/src/prefs/ModulePrefs.cpp @@ -163,7 +163,6 @@ void ModulePrefs::SetModuleStatus( wxString fname, int iStatus ){ PrefsPanel *ModulePrefsFactory::Create(wxWindow *parent) { - return new ModulePrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew ModulePrefs(parent); } - - diff --git a/src/prefs/MousePrefs.cpp b/src/prefs/MousePrefs.cpp index 30366f450..4e49aa059 100644 --- a/src/prefs/MousePrefs.cpp +++ b/src/prefs/MousePrefs.cpp @@ -205,5 +205,6 @@ bool MousePrefs::Apply() PrefsPanel *MousePrefsFactory::Create(wxWindow *parent) { - return new MousePrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew MousePrefs(parent); } diff --git a/src/prefs/PlaybackPrefs.cpp b/src/prefs/PlaybackPrefs.cpp index d3c56e5c3..eb816bd71 100644 --- a/src/prefs/PlaybackPrefs.cpp +++ b/src/prefs/PlaybackPrefs.cpp @@ -125,5 +125,6 @@ bool PlaybackPrefs::Apply() PrefsPanel *PlaybackPrefsFactory::Create(wxWindow *parent) { - return new PlaybackPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew PlaybackPrefs(parent); } diff --git a/src/prefs/PrefsPanel.h b/src/prefs/PrefsPanel.h index bd01b147b..77da3a042 100644 --- a/src/prefs/PrefsPanel.h +++ b/src/prefs/PrefsPanel.h @@ -64,6 +64,7 @@ class PrefsPanel:public wxPanel class PrefsPanelFactory { public: + // Precondition: parent != NULL virtual PrefsPanel *Create(wxWindow *parent) = 0; }; diff --git a/src/prefs/ProjectsPrefs.cpp b/src/prefs/ProjectsPrefs.cpp index fc1e07630..2238a4fc7 100644 --- a/src/prefs/ProjectsPrefs.cpp +++ b/src/prefs/ProjectsPrefs.cpp @@ -82,5 +82,6 @@ bool ProjectsPrefs::Apply() PrefsPanel *ProjectsPrefsFactory::Create(wxWindow *parent) { - return new ProjectsPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew ProjectsPrefs(parent); } diff --git a/src/prefs/QualityPrefs.cpp b/src/prefs/QualityPrefs.cpp index 1f7e54918..91c3b20af 100644 --- a/src/prefs/QualityPrefs.cpp +++ b/src/prefs/QualityPrefs.cpp @@ -230,5 +230,6 @@ bool QualityPrefs::Apply() PrefsPanel *QualityPrefsFactory::Create(wxWindow *parent) { - return new QualityPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew QualityPrefs(parent); } diff --git a/src/prefs/RecordingPrefs.cpp b/src/prefs/RecordingPrefs.cpp index c8b8d87ca..7c48120c5 100644 --- a/src/prefs/RecordingPrefs.cpp +++ b/src/prefs/RecordingPrefs.cpp @@ -252,5 +252,6 @@ void RecordingPrefs::OnToggleCustomName(wxCommandEvent & Evt) PrefsPanel *RecordingPrefsFactory::Create(wxWindow *parent) { - return new RecordingPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew RecordingPrefs(parent); } diff --git a/src/prefs/SpectrumPrefs.cpp b/src/prefs/SpectrumPrefs.cpp index dbfa339b9..bd16f2478 100644 --- a/src/prefs/SpectrumPrefs.cpp +++ b/src/prefs/SpectrumPrefs.cpp @@ -513,5 +513,6 @@ SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt) PrefsPanel *SpectrumPrefsFactory::Create(wxWindow *parent) { - return new SpectrumPrefs(parent, mWt); + wxASSERT(parent); // to justify safenew + return safenew SpectrumPrefs(parent, mWt); } diff --git a/src/prefs/ThemePrefs.cpp b/src/prefs/ThemePrefs.cpp index 628448336..d47c4a3f0 100644 --- a/src/prefs/ThemePrefs.cpp +++ b/src/prefs/ThemePrefs.cpp @@ -208,5 +208,6 @@ bool ThemePrefs::Apply() PrefsPanel *ThemePrefsFactory::Create(wxWindow *parent) { - return new ThemePrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew ThemePrefs(parent); } diff --git a/src/prefs/TracksPrefs.cpp b/src/prefs/TracksPrefs.cpp index a19f760e7..0c19c5658 100644 --- a/src/prefs/TracksPrefs.cpp +++ b/src/prefs/TracksPrefs.cpp @@ -164,5 +164,6 @@ bool TracksPrefs::Apply() PrefsPanel *TracksPrefsFactory::Create(wxWindow *parent) { - return new TracksPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew TracksPrefs(parent); } diff --git a/src/prefs/WarningsPrefs.cpp b/src/prefs/WarningsPrefs.cpp index c0cb5b47b..cb459028e 100644 --- a/src/prefs/WarningsPrefs.cpp +++ b/src/prefs/WarningsPrefs.cpp @@ -86,5 +86,6 @@ bool WarningsPrefs::Apply() PrefsPanel *WarningsPrefsFactory::Create(wxWindow *parent) { - return new WarningsPrefs(parent); + wxASSERT(parent); // to justify safenew + return safenew WarningsPrefs(parent); } diff --git a/src/prefs/WaveformPrefs.cpp b/src/prefs/WaveformPrefs.cpp index cb3e5b2cd..8a3b6bfb1 100644 --- a/src/prefs/WaveformPrefs.cpp +++ b/src/prefs/WaveformPrefs.cpp @@ -244,5 +244,6 @@ WaveformPrefsFactory::WaveformPrefsFactory(WaveTrack *wt) PrefsPanel *WaveformPrefsFactory::Create(wxWindow *parent) { - return new WaveformPrefs(parent, mWt); + wxASSERT(parent); // to justify safenew + return safenew WaveformPrefs(parent, mWt); } diff --git a/src/toolbars/EditToolBar.cpp b/src/toolbars/EditToolBar.cpp index 29eb7b785..b3a5b73b8 100644 --- a/src/toolbars/EditToolBar.cpp +++ b/src/toolbars/EditToolBar.cpp @@ -82,8 +82,6 @@ EditToolBar::EditToolBar() EditToolBar::~EditToolBar() { - for (int i=0; iSetScroll(0.1f, 2.0f); mInputSlider->SetName(_("Slider Recording")); @@ -97,7 +97,7 @@ void MixerToolBar::Populate() wxID_ANY, *mPlayBitmap), 0, wxALIGN_CENTER); - mOutputSlider = new ASlider(this, wxID_ANY, _("Playback Volume"), + mOutputSlider = safenew ASlider(this, wxID_ANY, _("Playback Volume"), wxDefaultPosition, wxSize(130, 25)); mOutputSlider->SetScroll(0.1f, 2.0f); mOutputSlider->SetName(_("Slider Playback")); diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 933d22c33..3cde5b5cb 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -251,13 +251,13 @@ void SelectionBar::Populate() NULL, this); - mLeftTime = new NumericTextCtrl( + mLeftTime = safenew NumericTextCtrl( NumericConverter::TIME, this, OnLeftTimeID, formatName, 0.0, mRate); mLeftTime->SetName(_("Selection Start:")); mLeftTime->EnableMenu(); mainSizer->Add(mLeftTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); - mRightTime = new NumericTextCtrl( + mRightTime = safenew NumericTextCtrl( NumericConverter::TIME, this, OnRightTimeID, formatName, 0.0, mRate); mRightTime->SetName(wxString(_("Selection ")) + (showSelectionLength ? _("Length") : @@ -270,7 +270,7 @@ void SelectionBar::Populate() wxLI_VERTICAL), 0, wxRIGHT, 5); - mAudioTime = new NumericTextCtrl( + mAudioTime = safenew NumericTextCtrl( NumericConverter::TIME, this, wxID_ANY, formatName, 0.0, mRate); mAudioTime->SetName(_("Audio Position:")); mAudioTime->EnableMenu(); diff --git a/src/toolbars/SpectralSelectionBar.cpp b/src/toolbars/SpectralSelectionBar.cpp index 75baa1d2b..6babe45b3 100644 --- a/src/toolbars/SpectralSelectionBar.cpp +++ b/src/toolbars/SpectralSelectionBar.cpp @@ -146,28 +146,28 @@ void SpectralSelectionBar::Populate() wxBoxSizer *subSizer = new wxBoxSizer(wxHORIZONTAL); - mCenterCtrl = new NumericTextCtrl( + mCenterCtrl = safenew NumericTextCtrl( NumericConverter::FREQUENCY, this, OnCenterID, frequencyFormatName, 0.0); mCenterCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); mCenterCtrl->SetName(_("Center Frequency:")); mCenterCtrl->EnableMenu(); subSizer->Add(mCenterCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); - mWidthCtrl = new NumericTextCtrl( + mWidthCtrl = safenew NumericTextCtrl( NumericConverter::BANDWIDTH, this, OnWidthID, bandwidthFormatName, 0.0); mWidthCtrl->SetInvalidValue(-1.0); mWidthCtrl->SetName(wxString(_("Bandwidth:"))); mWidthCtrl->EnableMenu(); subSizer->Add(mWidthCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); - mLowCtrl = new NumericTextCtrl( + mLowCtrl = safenew NumericTextCtrl( NumericConverter::FREQUENCY, this, OnLowID, frequencyFormatName, 0.0); mLowCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); mLowCtrl->SetName(_("Low Frequency:")); mLowCtrl->EnableMenu(); subSizer->Add(mLowCtrl, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); - mHighCtrl = new NumericTextCtrl( + mHighCtrl = safenew NumericTextCtrl( NumericConverter::FREQUENCY, this, OnHighID, frequencyFormatName, 0.0); mHighCtrl->SetInvalidValue(SelectedRegion::UndefinedFrequency); mHighCtrl->SetName(wxString(_("High Frequency:"))); diff --git a/src/toolbars/ToolBar.cpp b/src/toolbars/ToolBar.cpp index bdbaeeef7..2c51be010 100644 --- a/src/toolbars/ToolBar.cpp +++ b/src/toolbars/ToolBar.cpp @@ -426,7 +426,7 @@ void ToolBar::ReCreateButtons() wxBoxSizer *ms = new wxBoxSizer( wxHORIZONTAL ); // 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 ); // Use a box sizer for laying out controls @@ -443,7 +443,7 @@ void ToolBar::ReCreateButtons() if( IsResizable() ) { // 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 ); mResizer->SetToolTip( _("Click and drag to resize toolbar") ); } diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index 32a7b9370..4c46dfdb4 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -402,8 +402,8 @@ ToolManager::ToolManager( AudacityProject *parent ) this ); // Create the top and bottom docks - mTopDock = new ToolDock( this, mParent, TopDockID ); - mBotDock = new ToolDock( this, mParent, BotDockID ); + mTopDock = safenew ToolDock( this, mParent, TopDockID ); + mBotDock = safenew ToolDock( this, mParent, BotDockID ); // Create all of the toolbars mBars[ ToolsBarID ] = new ToolsToolBar(); @@ -542,7 +542,7 @@ void ToolManager::Reset() // Maybe construct a NEW floater // this happens if we have just been bounced out of a dock. if( floater == NULL ) { - floater = new ToolFrame( mParent, this, bar, wxPoint(-1,-1) ); + floater = safenew ToolFrame( mParent, this, bar, wxPoint(-1,-1) ); bar->Reparent( floater ); } @@ -710,7 +710,7 @@ void ToolManager::ReadConfig() // 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 if( width[ ndx ] != -1 && height[ ndx ] != -1 ) diff --git a/src/toolbars/ToolsToolBar.cpp b/src/toolbars/ToolsToolBar.cpp index b6d425fff..8e0dcd4ff 100644 --- a/src/toolbars/ToolsToolBar.cpp +++ b/src/toolbars/ToolsToolBar.cpp @@ -124,8 +124,6 @@ ToolsToolBar::ToolsToolBar() ToolsToolBar::~ToolsToolBar() { - for (int i = 0; i < 5; i++) - delete mTool[i]; } void ToolsToolBar::RegenerateToolsTooltips() diff --git a/src/toolbars/TranscriptionToolBar.cpp b/src/toolbars/TranscriptionToolBar.cpp index 6f800f593..c3d7c47f8 100644 --- a/src/toolbars/TranscriptionToolBar.cpp +++ b/src/toolbars/TranscriptionToolBar.cpp @@ -193,7 +193,7 @@ void TranscriptionToolBar::Populate() //Add a slider that controls the speed of playback. const int SliderWidth=100; - mPlaySpeedSlider = new ASlider(this, + mPlaySpeedSlider = safenew ASlider(this, TTB_PlaySpeedSlider, _("Playback Speed"), wxDefaultPosition, @@ -236,7 +236,7 @@ void TranscriptionToolBar::Populate() AddButton(bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate, TRANSLATABLE("Calibrate voicekey")); - mSensitivitySlider = new ASlider(this, + mSensitivitySlider = safenew ASlider(this, TTB_SensitivitySlider, TRANSLATABLE("Adjust Sensitivity"), wxDefaultPosition, diff --git a/src/widgets/ASlider.cpp b/src/widgets/ASlider.cpp index 9253909b4..aa437b77b 100644 --- a/src/widgets/ASlider.cpp +++ b/src/widgets/ASlider.cpp @@ -202,7 +202,7 @@ SliderDialog::SliderDialog(wxWindow * parent, wxWindowID id, 15); mTextCtrl->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); - mSlider = new ASlider(this, + mSlider = safenew ASlider(this, wxID_ANY, title, wxDefaultPosition, diff --git a/src/widgets/ExpandingToolBar.cpp b/src/widgets/ExpandingToolBar.cpp index 8ef806004..44f86395d 100644 --- a/src/widgets/ExpandingToolBar.cpp +++ b/src/widgets/ExpandingToolBar.cpp @@ -145,7 +145,7 @@ ExpandingToolBar::ExpandingToolBar(wxWindow* parent, ToolBarArea *toolBarParent = dynamic_cast(GetParent()); 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) wxImage hbar = theTheme.Image(bmpToolBarToggle); @@ -542,7 +542,7 @@ void ExpandingToolBar::StartMoving() ImageRoll tgtImageRoll = ImageRoll(ImageRoll::VerticalRoll, tgtImage, magicColor); - mTargetPanel = new ImageRollPanel(mAreaParent, -1, tgtImageRoll, + mTargetPanel = safenew ImageRollPanel(mAreaParent, -1, tgtImageRoll, wxDefaultPosition, wxDefaultSize, wxTRANSPARENT_WINDOW); @@ -622,7 +622,7 @@ void ExpandingToolBar::FinishMoving() if (!mAreaParent || !mSavedArrangement) return; - delete mTargetPanel; + // DELETE mTargetPanel; // I think this is not needed, but unreachable anyway -- PRL mAreaParent->SetCapturedChild(NULL); diff --git a/src/widgets/Grid.cpp b/src/widgets/Grid.cpp index bfadd8d5d..bc3ba3d81 100644 --- a/src/widgets/Grid.cpp +++ b/src/widgets/Grid.cpp @@ -44,7 +44,8 @@ TimeEditor::~TimeEditor() 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, mFormat, mOld, diff --git a/src/widgets/Grid.h b/src/widgets/Grid.h index fd40ad2f2..60d7ed74e 100644 --- a/src/widgets/Grid.h +++ b/src/widgets/Grid.h @@ -45,6 +45,7 @@ class TimeEditor:public wxGridCellEditor ~TimeEditor(); + // Precondition: parent != NULL void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *handler); bool IsAcceptedKey(wxKeyEvent &event);