diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp index b75d5b803..131fd7948 100644 --- a/src/AboutDialog.cpp +++ b/src/AboutDialog.cpp @@ -194,7 +194,7 @@ AboutDialog::AboutDialog(wxWindow * parent) * In English it is slightly humorous alternative to an 'OK' button. * If the humour doesn't work in your language, then just use whatever * you would use for a translation for 'OK' on a button. */ - wxButton *ok = new wxButton(S.GetParent(), wxID_OK, _("OK... Audacious!")); + wxButton *ok = safenew wxButton(S.GetParent(), wxID_OK, _("OK... Audacious!")); ok->SetDefault(); S.Prop(0).AddWindow( ok ); @@ -286,7 +286,7 @@ visit our forum."); S.StartVerticalLay(1); //v For now, change to AudacityLogoWithName via old-fashioned way, not Theme. - logo = new wxBitmap((const char **) AudacityLogoWithName_xpm); //v + wxBitmap *const logo = new wxBitmap((const char **) AudacityLogoWithName_xpm); //v // JKC: Resize to 50% of size. Later we may use a smaller xpm as // our source, but this allows us to tweak the size - if we want to. @@ -298,7 +298,7 @@ visit our forum."); wxBitmap RescaledBitmap( RescaledImage ); icon = - new wxStaticBitmap(S.GetParent(), -1, + safenew wxStaticBitmap(S.GetParent(), -1, //*logo, //v //v theTheme.Bitmap(bmpAudacityLogo), wxPoint(93, 10), wxSize(215, 190)); //v theTheme.Bitmap(bmpAudacityLogoWithName), @@ -308,7 +308,7 @@ visit our forum."); delete logo; S.Prop(0).AddWindow( icon ); - HtmlWindow *html = new LinkingHtmlWindow(S.GetParent(), -1, + HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition, wxSize(ABOUT_DIALOG_WIDTH, 359), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER); @@ -332,7 +332,7 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S ) wxString informationStr; // string to build up list of information in S.StartNotebookPage( _("Build Information") ); // start the tab S.StartVerticalLay(2); // create the window - HtmlWindow *html = new LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition, + HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition, wxSize(ABOUT_DIALOG_WIDTH, 264), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER); // create a html pane in it to put the content in. @@ -559,7 +559,7 @@ void AboutDialog::PopulateLicensePage( ShuttleGui & S ) { S.StartNotebookPage( _("GPL License") ); S.StartVerticalLay(1); - HtmlWindow *html = new LinkingHtmlWindow(S.GetParent(), -1, + HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition, wxSize(ABOUT_DIALOG_WIDTH, 264), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER); @@ -918,8 +918,6 @@ void AboutDialog::AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, AboutDialog::~AboutDialog() { - delete icon; -// delete logo; } void AboutDialog::OnOK(wxCommandEvent & WXUNUSED(event)) diff --git a/src/AboutDialog.h b/src/AboutDialog.h index b4abf440f..ff8e2fb8a 100644 --- a/src/AboutDialog.h +++ b/src/AboutDialog.h @@ -54,7 +54,6 @@ class AboutDialog:public wxDialog { wxBoxSizer *topsizer; wxStaticBitmap *icon; - wxBitmap *logo; //v DECLARE_EVENT_TABLE() diff --git a/src/BatchProcessDialog.cpp b/src/BatchProcessDialog.cpp index 8413f5206..c54a9e6bb 100644 --- a/src/BatchProcessDialog.cpp +++ b/src/BatchProcessDialog.cpp @@ -152,7 +152,7 @@ void BatchProcessDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event)) } wxString name = mChains->GetItemText(item); - wxDialog * pD = new wxDialog(this, wxID_ANY, GetTitle()); + wxDialog * pD = safenew wxDialog(this, wxID_ANY, GetTitle()); pD->SetName(pD->GetTitle()); ShuttleGui S(pD, eIsCreating); @@ -292,7 +292,7 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event)) files.Sort(); - wxDialog * pD = new wxDialog(this, wxID_ANY, GetTitle()); + wxDialog * pD = safenew wxDialog(this, wxID_ANY, GetTitle()); pD->SetName(pD->GetTitle()); ShuttleGui S(pD, eIsCreating); diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index f5ffb3cbf..d7fb23ae7 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -304,7 +304,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, { S.StartVerticalLay(); { - mPanScroller = new wxScrollBar(this, FreqPanScrollerID, + mPanScroller = safenew wxScrollBar(this, FreqPanScrollerID, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL); mPanScroller->SetName(_("Scroll")); S.Prop(1); @@ -314,12 +314,12 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, S.StartVerticalLay(); { - wxStaticBitmap *zi = new wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomIn)); + wxStaticBitmap *zi = safenew wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomIn)); S.AddWindow((wxWindow *) zi, wxALIGN_CENTER); S.AddSpace(5); - mZoomSlider = new wxSlider(this, FreqZoomSliderID, 100, 1, 100, + mZoomSlider = safenew wxSlider(this, FreqZoomSliderID, 100, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL); S.Prop(1); S.AddWindow(mZoomSlider, wxALIGN_CENTER_HORIZONTAL); @@ -327,7 +327,7 @@ FreqWindow::FreqWindow(wxWindow * parent, wxWindowID id, S.AddSpace(5); - wxStaticBitmap *zo = new wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomOut)); + wxStaticBitmap *zo = safenew wxStaticBitmap(this, wxID_ANY, wxBitmap(ZoomOut)); S.AddWindow((wxWindow *) zo, wxALIGN_CENTER); } S.EndVerticalLay(); diff --git a/src/HistoryWindow.cpp b/src/HistoryWindow.cpp index 9e959a825..86db27bc3 100644 --- a/src/HistoryWindow.cpp +++ b/src/HistoryWindow.cpp @@ -98,7 +98,7 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager): S.AddVariableText(wxT(""))->Hide(); S.AddPrompt(_("&Levels To Discard")); - mLevels = new wxSpinCtrl(this, + mLevels = safenew wxSpinCtrl(this, ID_LEVELS, wxT("1"), wxDefaultPosition, diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index 037811731..ad0bf463b 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -110,7 +110,7 @@ LabelDialog::LabelDialog(wxWindow *parent, // A little instruction wxStaticText *instruct = - new wxStaticText(this, + safenew wxStaticText(this, wxID_ANY, _("Press F2 or double click to edit cell contents.")); instruct->SetName(instruct->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) @@ -125,11 +125,11 @@ LabelDialog::LabelDialog(wxWindow *parent, // Create the action buttons wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL); - hs->Add(new wxButton(this, ID_INSERTA, _("Insert &After")), 1, wxCENTER | wxALL, 5); - hs->Add(new wxButton(this, ID_INSERTB, _("Insert &Before")), 1, wxCENTER | wxALL, 5); - hs->Add(new wxButton(this, ID_REMOVE, _("&Remove")), 1, wxCENTER | wxALL, 5); - hs->Add(new wxButton(this, ID_IMPORT, _("&Import...")), 1, wxCENTER | wxALL, 5); - hs->Add(new wxButton(this, ID_EXPORT, _("&Export...")), 1, wxCENTER | wxALL, 5); + hs->Add(safenew wxButton(this, ID_INSERTA, _("Insert &After")), 1, wxCENTER | wxALL, 5); + hs->Add(safenew wxButton(this, ID_INSERTB, _("Insert &Before")), 1, wxCENTER | wxALL, 5); + hs->Add(safenew wxButton(this, ID_REMOVE, _("&Remove")), 1, wxCENTER | wxALL, 5); + hs->Add(safenew wxButton(this, ID_IMPORT, _("&Import...")), 1, wxCENTER | wxALL, 5); + hs->Add(safenew wxButton(this, ID_EXPORT, _("&Export...")), 1, wxCENTER | wxALL, 5); vs->Add(hs, 0, wxEXPAND | wxCENTER | wxALL, 5); // Create the exit buttons diff --git a/src/LyricsWindow.cpp b/src/LyricsWindow.cpp index c25bf7e87..b2c82937b 100644 --- a/src/LyricsWindow.cpp +++ b/src/LyricsWindow.cpp @@ -86,8 +86,9 @@ LyricsWindow::LyricsWindow(AudacityProject *parent): // //wxToolBar* pToolBar = this->CreateToolBar(); //const int kHorizMargin = 8; + //wxASSERT(pToolBar); // To justify safenew //wxRadioButton* pRadioButton_BouncingBall = - // new wxRadioButton(pToolBar, kID_RadioButton_BouncingBall, _("Bouncing Ball"), wxPoint(kHorizMargin, 4), + // safenew wxRadioButton(pToolBar, kID_RadioButton_BouncingBall, _("Bouncing Ball"), wxPoint(kHorizMargin, 4), // wxDefaultSize, wxRB_GROUP); //// Reposition to center vertically. //wxSize tbSize = pToolBar->GetSize(); @@ -98,7 +99,7 @@ LyricsWindow::LyricsWindow(AudacityProject *parent): // //int left = kHorizMargin + btnSize.GetWidth() + kHorizMargin; //vvv Doesn't actually work. Probably need sizers. //wxRadioButton* pRadioButton_Highlight = - // new wxRadioButton(pToolBar, kID_RadioButton_Highlight, _("Highlight"), wxPoint(left, top)); + // safenew wxRadioButton(pToolBar, kID_RadioButton_Highlight, _("Highlight"), wxPoint(left, top)); //pToolBar->AddControl(pRadioButton_Highlight); // //panelPos.x += tbSize.GetHeight(); diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 4c2adee1a..6e84038cd 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -190,10 +190,10 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, wxSize ctrlSize(size.GetWidth() - kQuadrupleInset, TRACK_NAME_HEIGHT); mStaticText_TrackName = #ifdef EXPERIMENTAL_MIDI_OUT - new wxStaticText(this, -1, mTrack->GetName(), ctrlPos, ctrlSize, + safenew wxStaticText(this, -1, mTrack->GetName(), ctrlPos, ctrlSize, wxALIGN_CENTRE | wxST_NO_AUTORESIZE | wxSUNKEN_BORDER); #else - new wxStaticText(this, -1, mLeftTrack->GetName(), ctrlPos, ctrlSize, + safenew wxStaticText(this, -1, mLeftTrack->GetName(), ctrlPos, ctrlSize, wxALIGN_CENTRE | 0x0001 | wxBORDER_SUNKEN); #endif //v Useful when different tracks are different colors, but not now. @@ -241,7 +241,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, #endif wxASSERT(bitmap); mBitmapButton_MusicalInstrument = - new wxBitmapButton(this, ID_BITMAPBUTTON_MUSICAL_INSTRUMENT, *bitmap, + safenew wxBitmapButton(this, ID_BITMAPBUTTON_MUSICAL_INSTRUMENT, *bitmap, ctrlPos, ctrlSize, wxBU_AUTODRAW, wxDefaultValidator, _("Musical Instrument")); diff --git a/src/Project.cpp b/src/Project.cpp index d1153148e..4393bf2ca 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -923,7 +923,7 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, // Not using a notebook, so we place the track panel inside another panel, // this keeps the notebook code and normal code consistant and also // paves the way for adding additional windows inside the track panel. - mMainPanel = new wxPanel(this, -1, + mMainPanel = safenew wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); diff --git a/src/Screenshot.cpp b/src/Screenshot.cpp index a7782c591..97d7ad124 100644 --- a/src/Screenshot.cpp +++ b/src/Screenshot.cpp @@ -333,13 +333,14 @@ void ScreenFrame::PopulateOrExchange(ShuttleGui & S) S.Id(IdMainWindowLarge).AddButton(_("Resize Large")); /* i18n-hint: Bkgnd is short for background and appears on a small button * It is OK to just translate this item as if it said 'Blue' */ - mBlue = new wxToggleButton(p, + wxASSERT(p); // To justify safenew + mBlue = safenew wxToggleButton(p, IdToggleBackgroundBlue, _("Blue Bkgnd")); S.AddWindow(mBlue); /* i18n-hint: Bkgnd is short for background and appears on a small button * It is OK to just translate this item as if it said 'White' */ - mWhite = new wxToggleButton(p, + mWhite = safenew wxToggleButton(p, IdToggleBackgroundWhite, _("White Bkgnd")); S.AddWindow(mWhite); diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index 6890e8443..ba36fd569 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -95,6 +95,7 @@ for registering for changes. #include "Audacity.h" +#include #include #include #include @@ -216,7 +217,7 @@ void ShuttleGuiBase::AddPrompt(const wxString &Prompt) if( mShuttleMode != eIsCreating ) return; miProp=1; - mpWind = new wxStaticText(mpParent, -1, Prompt, wxDefaultPosition, wxDefaultSize, + mpWind = safenew wxStaticText(GetParent(), -1, Prompt, wxDefaultPosition, wxDefaultSize, Style( wxALIGN_RIGHT )); mpWind->SetName(wxStripMenuCodes(Prompt)); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) UpdateSizersCore( false, wxALL | wxALIGN_CENTRE_VERTICAL ); @@ -230,7 +231,7 @@ void ShuttleGuiBase::AddUnits(const wxString &Prompt) if( mShuttleMode != eIsCreating ) return; miProp=1; - mpWind = new wxStaticText(mpParent, -1, Prompt, wxDefaultPosition, wxDefaultSize, + mpWind = safenew wxStaticText(GetParent(), -1, Prompt, wxDefaultPosition, wxDefaultSize, Style( wxALIGN_LEFT )); mpWind->SetName(Prompt); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) UpdateSizersCore( false, wxALL | wxALIGN_LEFT ); @@ -243,7 +244,7 @@ void ShuttleGuiBase::AddTitle(const wxString &Prompt) return; if( mShuttleMode != eIsCreating ) return; - mpWind = new wxStaticText(mpParent, -1, Prompt, wxDefaultPosition, wxDefaultSize, + mpWind = safenew wxStaticText(GetParent(), -1, Prompt, wxDefaultPosition, wxDefaultSize, Style( wxALIGN_CENTRE )); mpWind->SetName(Prompt); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) UpdateSizers(); @@ -268,7 +269,7 @@ wxCheckBox * ShuttleGuiBase::AddCheckBox( const wxString &Prompt, const wxString return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxCheckBox); wxCheckBox * pCheckBox; miProp=0; - mpWind = pCheckBox = new wxCheckBox(mpParent, miId, Prompt, wxDefaultPosition, wxDefaultSize, + mpWind = pCheckBox = safenew wxCheckBox(GetParent(), miId, Prompt, wxDefaultPosition, wxDefaultSize, Style( 0 )); pCheckBox->SetValue(Selected == wxT("true")); pCheckBox->SetName(wxStripMenuCodes(Prompt)); @@ -287,7 +288,7 @@ wxCheckBox * ShuttleGuiBase::AddCheckBoxOnRight( const wxString &Prompt, const w wxCheckBox * pCheckBox; miProp=0; AddPrompt( Prompt ); - mpWind = pCheckBox = new wxCheckBox(mpParent, miId, wxT(""), wxDefaultPosition, wxDefaultSize, + mpWind = pCheckBox = safenew wxCheckBox(GetParent(), miId, wxT(""), wxDefaultPosition, wxDefaultSize, Style( 0 )); pCheckBox->SetValue(Selected==wxT("true")); pCheckBox->SetName(wxStripMenuCodes(Prompt)); @@ -301,7 +302,7 @@ wxButton * ShuttleGuiBase::AddButton(const wxString &Text, int PositionFlags) if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxButton); wxButton * pBtn; - mpWind = pBtn = new wxButton( mpParent, miId, Text, wxDefaultPosition, wxDefaultSize, + mpWind = pBtn = safenew wxButton(GetParent(), miId, Text, wxDefaultPosition, wxDefaultSize, Style( 0 ) ); mpWind->SetName(wxStripMenuCodes(Text)); miProp=0; @@ -315,7 +316,7 @@ wxBitmapButton * ShuttleGuiBase::AddBitmapButton(const wxBitmap &Bitmap, int Pos if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxBitmapButton); wxBitmapButton * pBtn; - mpWind = pBtn = new wxBitmapButton( mpParent, miId, Bitmap, + mpWind = pBtn = safenew wxBitmapButton(GetParent(), miId, Bitmap, wxDefaultPosition, wxDefaultSize, Style( wxNO_BORDER ) ); pBtn->SetBackgroundColour( wxColour( 246,246,243)); @@ -334,8 +335,8 @@ wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt, const wxString &Se miProp=0; AddPrompt( Prompt ); - mpWind = pChoice = new wxChoice( - mpParent, + mpWind = pChoice = safenew wxChoice( + GetParent(), miId, wxDefaultPosition, wxDefaultSize, @@ -355,7 +356,7 @@ void ShuttleGuiBase::AddFixedText(const wxString &Str, bool bCenter) UseUpId(); if( mShuttleMode != eIsCreating ) return; - mpWind = new wxStaticText(mpParent, miId, Str, wxDefaultPosition, wxDefaultSize, + mpWind = safenew wxStaticText(GetParent(), miId, Str, wxDefaultPosition, wxDefaultSize, Style( wxALIGN_LEFT )); mpWind->SetName(wxStripMenuCodes(Str)); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) if( bCenter ) @@ -374,7 +375,7 @@ wxStaticText * ShuttleGuiBase::AddVariableText(const wxString &Str, bool bCenter return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxStaticText); wxStaticText *pStatic; - mpWind = pStatic = new wxStaticText(mpParent, miId, Str, wxDefaultPosition, wxDefaultSize, + mpWind = pStatic = safenew wxStaticText(GetParent(), miId, Str, wxDefaultPosition, wxDefaultSize, Style( wxALIGN_LEFT )); mpWind->SetName(wxStripMenuCodes(Str)); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) if( bCenter ) @@ -412,7 +413,7 @@ wxComboBox * ShuttleGuiBase::AddCombo( const wxString &Prompt, const wxString &S AddPrompt( Prompt ); - mpWind = pCombo = new wxComboBox(mpParent, miId, Selected, wxDefaultPosition, wxDefaultSize, + mpWind = pCombo = safenew wxComboBox(GetParent(), miId, Selected, wxDefaultPosition, wxDefaultSize, n, Choices, Style( style )); mpWind->SetName(wxStripMenuCodes(Prompt)); @@ -429,7 +430,7 @@ wxRadioButton * ShuttleGuiBase::AddRadioButton(const wxString &Prompt) if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxRadioButton); wxRadioButton * pRad; - mpWind = pRad = new wxRadioButton( mpParent, miId, Prompt, + mpWind = pRad = safenew wxRadioButton(GetParent(), miId, Prompt, wxDefaultPosition, wxDefaultSize, Style( wxRB_GROUP ) ); mpWind->SetName(wxStripMenuCodes(Prompt)); pRad->SetValue(true ); @@ -443,7 +444,7 @@ wxRadioButton * ShuttleGuiBase::AddRadioButtonToGroup(const wxString &Prompt) if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxRadioButton); wxRadioButton * pRad; - mpWind = pRad = new wxRadioButton( mpParent, miId, Prompt, + mpWind = pRad = safenew wxRadioButton(GetParent(), miId, Prompt, wxDefaultPosition, wxDefaultSize, Style( 0 ) ); mpWind->SetName(wxStripMenuCodes(Prompt)); UpdateSizers(); @@ -457,7 +458,7 @@ wxSlider * ShuttleGuiBase::AddSlider(const wxString &Prompt, int pos, int Max, i return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxSlider); AddPrompt( Prompt ); wxSlider * pSlider; - mpWind = pSlider = new wxSlider( mpParent, miId, + mpWind = pSlider = safenew wxSlider(GetParent(), miId, pos, Min, Max, wxDefaultPosition, wxDefaultSize, Style( wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS ) @@ -475,7 +476,7 @@ wxSpinCtrl * ShuttleGuiBase::AddSpinCtrl(const wxString &Prompt, int Value, int return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxSpinCtrl); AddPrompt( Prompt ); wxSpinCtrl * pSpinCtrl; - mpWind = pSpinCtrl = new wxSpinCtrl( mpParent, miId, + mpWind = pSpinCtrl = safenew wxSpinCtrl(GetParent(), miId, wxEmptyString, wxDefaultPosition, wxDefaultSize, Style( wxSP_VERTICAL | wxSP_ARROW_KEYS ), @@ -508,7 +509,7 @@ wxTextCtrl * ShuttleGuiBase::AddTextBox(const wxString &Caption, const wxString long flags = wxTE_LEFT; #endif - mpWind = pTextCtrl = new wxTextCtrl(mpParent, miId, Value, + mpWind = pTextCtrl = safenew wxTextCtrl(GetParent(), miId, Value, wxDefaultPosition, Size, Style( flags )); mpWind->SetName(wxStripMenuCodes(Caption)); UpdateSizers(); @@ -536,7 +537,7 @@ wxTextCtrl * ShuttleGuiBase::AddNumericTextBox(const wxString &Caption, const wx #endif wxTextValidator Validator(wxFILTER_NUMERIC); - mpWind = pTextCtrl = new wxTextCtrl(mpParent, miId, Value, + mpWind = pTextCtrl = safenew wxTextCtrl(GetParent(), miId, Value, wxDefaultPosition, Size, Style( flags ), Validator // It's OK to pass this. It will be cloned. ); @@ -553,7 +554,7 @@ wxTextCtrl * ShuttleGuiBase::AddTextWindow(const wxString &Value) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxTextCtrl); wxTextCtrl * pTextCtrl; SetProportions( 1 ); - mpWind = pTextCtrl = new wxTextCtrl(mpParent, miId, Value, + mpWind = pTextCtrl = safenew wxTextCtrl(GetParent(), miId, Value, wxDefaultPosition, wxDefaultSize, Style( wxTE_MULTILINE )); UpdateSizers(); // Start off at start of window... @@ -573,7 +574,7 @@ void ShuttleGuiBase::AddConstTextBox(const wxString &Prompt, const wxString &Val AddPrompt( Prompt ); UpdateSizers(); miProp=0; - mpWind = new wxStaticText(mpParent, miId, Value, wxDefaultPosition, wxDefaultSize, + mpWind = safenew wxStaticText(GetParent(), miId, Value, wxDefaultPosition, wxDefaultSize, Style( 0 )); mpWind->SetName(Value); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) UpdateSizers(); @@ -586,7 +587,7 @@ wxListBox * ShuttleGuiBase::AddListBox(const wxArrayString * pChoices, long styl return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxListBox); wxListBox * pListBox; SetProportions( 1 ); - mpWind = pListBox = new wxListBox(mpParent, miId, + mpWind = pListBox = safenew wxListBox(GetParent(), miId, wxDefaultPosition, wxDefaultSize,*pChoices, style); pListBox->SetMinSize( wxSize( 120,150 )); UpdateSizers(); @@ -601,7 +602,7 @@ wxListCtrl * ShuttleGuiBase::AddListControl() return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxListCtrl); wxListCtrl * pListCtrl; SetProportions( 1 ); - mpWind = pListCtrl = new wxListCtrl(mpParent, miId, + mpWind = pListCtrl = safenew wxListCtrl(GetParent(), miId, wxDefaultPosition, wxDefaultSize, Style( wxLC_ICON )); pListCtrl->SetMinSize( wxSize( 120,150 )); UpdateSizers(); @@ -615,7 +616,7 @@ wxGrid * ShuttleGuiBase::AddGrid() return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxGrid); wxGrid * pGrid; SetProportions( 1 ); - mpWind = pGrid = new wxGrid(mpParent, miId, wxDefaultPosition, + mpWind = pGrid = safenew wxGrid(GetParent(), miId, wxDefaultPosition, wxDefaultSize, Style( wxWANTS_CHARS )); pGrid->SetMinSize( wxSize( 120, 150 )); UpdateSizers(); @@ -629,7 +630,7 @@ wxListCtrl * ShuttleGuiBase::AddListControlReportMode() return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxListCtrl); wxListCtrl * pListCtrl; SetProportions( 1 ); - mpWind = pListCtrl = new wxListCtrl(mpParent, miId, + mpWind = pListCtrl = safenew wxListCtrl(GetParent(), miId, wxDefaultPosition, wxSize(230,120),//wxDefaultSize, Style( wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxSUNKEN_BORDER )); // pListCtrl->SetMinSize( wxSize( 120,150 )); @@ -644,7 +645,7 @@ wxTreeCtrl * ShuttleGuiBase::AddTree() return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxTreeCtrl); wxTreeCtrl * pTreeCtrl; SetProportions( 1 ); - mpWind = pTreeCtrl = new wxTreeCtrl(mpParent, miId, wxDefaultPosition, wxDefaultSize, + mpWind = pTreeCtrl = safenew wxTreeCtrl(GetParent(), miId, wxDefaultPosition, wxDefaultSize, Style( wxTR_HAS_BUTTONS )); pTreeCtrl->SetMinSize( wxSize( 120,650 )); UpdateSizers(); @@ -658,7 +659,7 @@ void ShuttleGuiBase::AddIcon(wxBitmap *pBmp) // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx); return; wxBitmapButton * pBtn; - mpWind = pBtn = new wxBitmapButton( mpParent, miId, *pBmp, + mpWind = pBtn = safenew wxBitmapButton(GetParent(), miId, *pBmp, wxDefaultPosition, wxDefaultSize, Style( wxBU_AUTODRAW ) ); pBtn->SetWindowStyle( 0 ); UpdateSizersC(); @@ -702,7 +703,7 @@ wxStaticBox * ShuttleGuiBase::StartStatic(const wxString &Str, int iProp) mBoxName = Str; if( mShuttleMode != eIsCreating ) return NULL; - wxStaticBox * pBox = new wxStaticBox(mpParent, miId, + wxStaticBox * pBox = safenew wxStaticBox(GetParent(), miId, Str ); pBox->SetLabel( Str ); pBox->SetName(wxStripMenuCodes(Str)); @@ -736,7 +737,7 @@ wxScrolledWindow * ShuttleGuiBase::StartScroller(int iStyle) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxScrolledWindow); wxScrolledWindow * pScroller; - mpWind = pScroller = new wxScrolledWindow( mpParent, miId, wxDefaultPosition, wxDefaultSize, + mpWind = pScroller = safenew wxScrolledWindow(GetParent(), miId, wxDefaultPosition, wxDefaultSize, Style( wxSUNKEN_BORDER ) ); pScroller->SetScrollRate( 20,20 ); @@ -792,7 +793,7 @@ wxPanel * ShuttleGuiBase::StartPanel(int iStyle) if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxPanel); wxPanel * pPanel; - mpWind = pPanel = new wxPanel( mpParent, miId, wxDefaultPosition, wxDefaultSize, + mpWind = pPanel = safenew wxPanel( GetParent(), miId, wxDefaultPosition, wxDefaultSize, Style( wxNO_BORDER )); if( iStyle != 0 ) @@ -829,7 +830,7 @@ wxNotebook * ShuttleGuiBase::StartNotebook() if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxNotebook); wxNotebook * pNotebook; - mpWind = pNotebook = new wxNotebook(mpParent, + mpWind = pNotebook = safenew wxNotebook(GetParent(), miId, wxDefaultPosition, wxDefaultSize, Style( 0 )); SetProportions( 1 ); UpdateSizers(); @@ -850,7 +851,7 @@ wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const wxString & Name ) return NULL; // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx); wxNotebook * pNotebook = (wxNotebook*)mpParent; - wxNotebookPage * pPage = new wxPanel(mpParent ); + wxNotebookPage * pPage = safenew wxPanel(GetParent()); pPage->SetName(Name); pNotebook->AddPage( @@ -873,7 +874,7 @@ void ShuttleGuiBase::StartNotebookPage( const wxString & Name, wxNotebookPage * return; // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx); wxNotebook * pNotebook = (wxNotebook*)mpParent; -// wxNotebookPage * pPage = new wxPanel(mpParent ); +// wxNotebookPage * pPage = safenew wxPanel(GetParent()); pPage->Create( mpParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxT("panel")); pPage->SetName(Name); @@ -937,7 +938,7 @@ wxPanel * ShuttleGuiBase::StartInvisiblePanel() if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxPanel); wxPanel * pPanel; - mpWind = pPanel = new wxPanel( mpParent, miId, wxDefaultPosition, wxDefaultSize, + mpWind = pPanel = safenew wxPanel(GetParent(), miId, wxDefaultPosition, wxDefaultSize, wxNO_BORDER); mpWind->SetBackgroundColour( @@ -1343,7 +1344,7 @@ wxRadioButton * ShuttleGuiBase::TieRadioButton(const wxString &Prompt, WrappedTy { case eIsCreating: { - mpWind = pRadioButton = new wxRadioButton( mpParent, miId, Prompt, + mpWind = pRadioButton = safenew wxRadioButton(GetParent(), miId, Prompt, wxDefaultPosition, wxDefaultSize, (mRadioCount==1)?wxRB_GROUP:0); pRadioButton->SetValue(WrappedRef.ValuesMatch( mRadioValue )); @@ -2117,77 +2118,80 @@ AttachableScrollBar * ShuttleGui::AddAttachableScrollBar( long style ) wxSizer *CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra) { - wxButton *b = new wxButton( parent, 0, wxEmptyString ); + wxASSERT(parent != NULL); // To justify safenew + int margin; - + { #if defined(__WXMAC__) - margin = 12; + margin = 12; #elif defined(__WXGTK20__) - margin = 12; + margin = 12; #elif defined(__WXMSW__) - margin = b->ConvertDialogToPixels( wxSize( 2, 0 ) ).x; + wxButton b(parent, 0, wxEmptyString); + margin = b.ConvertDialogToPixels(wxSize(2, 0)).x; #else - margin = b->ConvertDialogToPixels( wxSize( 4, 0 ) ).x; + wxButton b(parent, 0, wxEmptyString); + margin = b->ConvertDialogToPixels(wxSize(4, 0)).x; #endif + } - delete b; - + wxButton *b = NULL; wxStdDialogButtonSizer *bs = new wxStdDialogButtonSizer(); if( buttons & eOkButton ) { - b = new wxButton( parent, wxID_OK ); + b = safenew wxButton(parent, wxID_OK); b->SetDefault(); bs->AddButton( b ); } if( buttons & eCancelButton ) { - bs->AddButton( new wxButton( parent, wxID_CANCEL ) ); + bs->AddButton(safenew wxButton(parent, wxID_CANCEL)); } if( buttons & eYesButton ) { - b = new wxButton( parent, wxID_YES ); + b = safenew wxButton(parent, wxID_YES); b->SetDefault(); bs->AddButton( b ); } if( buttons & eNoButton ) { - bs->AddButton( new wxButton( parent, wxID_NO ) ); + bs->AddButton(safenew wxButton(parent, wxID_NO)); } if( buttons & eApplyButton ) { - b = new wxButton( parent, wxID_APPLY ); + b = safenew wxButton(parent, wxID_APPLY); b->SetDefault(); bs->AddButton( b ); } if( buttons & eCloseButton ) { - bs->AddButton( new wxButton( parent, wxID_CANCEL, _("&Close") ) ); + bs->AddButton(safenew wxButton(parent, wxID_CANCEL, _("&Close"))); } if( buttons & eHelpButton ) { - bs->AddButton( new wxButton( parent, wxID_HELP ) ); + bs->AddButton(safenew wxButton(parent, wxID_HELP)); } if (buttons & ePreviewButton) { - bs->Add( new wxButton( parent, ePreviewID, _("Pre&view") ), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin ); + bs->Add(safenew wxButton(parent, ePreviewID, _("Pre&view")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin); } if (buttons & ePreviewDryButton) { - bs->Add(new wxButton( parent, ePreviewDryID, _("Dry Previe&w") ), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin ); + bs->Add(safenew wxButton(parent, ePreviewDryID, _("Dry Previe&w")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin); bs->Add( 20, 0 ); } if( buttons & eSettingsButton ) { - bs->Add(new wxButton( parent, eSettingsID, _("&Settings") ), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin ); + bs->Add(safenew wxButton(parent, eSettingsID, _("&Settings")), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin); bs->Add( 20, 0 ); } @@ -2218,7 +2222,7 @@ wxSizer *CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra) } } - b = new wxButton( parent, eDebugID, _("Debu&g") ); + b = safenew wxButton(parent, eDebugID, _("Debu&g")); bs->Insert( lastLastSpacer + 1, b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin ); } diff --git a/src/ShuttleGui.h b/src/ShuttleGui.h index 2d05a0cbe..af83a19e0 100644 --- a/src/ShuttleGui.h +++ b/src/ShuttleGui.h @@ -256,7 +256,13 @@ public: void SetStretchyRow( int i ); //--Some Additions since June 2007 that don't fit in elsewhere... - wxWindow * GetParent() {return mpParent;}; + wxWindow * GetParent() + { + // This assertion justifies the use of safenew in many places where GetParent() + // is used to construct a window + wxASSERT(mpParent != NULL); + return mpParent; + } ShuttleGuiBase & Prop( int iProp ); int GetId() {return miIdNext;}; void UseUpId(); diff --git a/src/SplashDialog.cpp b/src/SplashDialog.cpp index bc487fd2b..bdc84076c 100644 --- a/src/SplashDialog.cpp +++ b/src/SplashDialog.cpp @@ -65,7 +65,6 @@ SplashDialog::SplashDialog(wxWindow * parent) { SetName(GetTitle()); this->SetBackgroundColour(theTheme.Colour( clrAboutBoxBackground )); - m_pIcon = NULL; m_pLogo = NULL; //v ShuttleGui S( this, eIsCreating ); Populate( S ); @@ -94,16 +93,16 @@ void SplashDialog::Populate( ShuttleGui & S ) // wxIMAGE_QUALITY_HIGH not supported by wxWidgets 2.6.1, or we would use it here. RescaledImage.Rescale( int(LOGOWITHNAME_WIDTH * fScale), int(LOGOWITHNAME_HEIGHT *fScale) ); wxBitmap RescaledBitmap( RescaledImage ); - m_pIcon = - new wxStaticBitmap(S.GetParent(), -1, + wxStaticBitmap *const icon = + safenew wxStaticBitmap(S.GetParent(), -1, //*m_pLogo, //v theTheme.Bitmap(bmpAudacityLogoWithName), RescaledBitmap, wxDefaultPosition, wxSize(int(LOGOWITHNAME_WIDTH*fScale), int(LOGOWITHNAME_HEIGHT*fScale))); - S.Prop(0).AddWindow( m_pIcon ); + S.Prop(0).AddWindow( icon ); - mpHtml = new LinkingHtmlWindow(S.GetParent(), -1, + mpHtml = safenew LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition, wxSize(506, 280), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER ); @@ -114,7 +113,7 @@ void SplashDialog::Populate( ShuttleGui & S ) { S.SetBorder( 5 ); S.Id( DontShowID).AddCheckBox( _("Don't show this again at start up"), bShow ? wxT("false") : wxT("true") ); - wxButton *ok = new wxButton(S.GetParent(), wxID_OK); + wxButton *ok = safenew wxButton(S.GetParent(), wxID_OK); ok->SetDefault(); S.SetBorder( 5 ); S.Prop(0).AddWindow( ok, wxALIGN_RIGHT| wxALL ); @@ -124,7 +123,6 @@ void SplashDialog::Populate( ShuttleGui & S ) SplashDialog::~SplashDialog() { - delete m_pIcon; delete m_pLogo; } diff --git a/src/SplashDialog.h b/src/SplashDialog.h index 36e87427a..e2d7748e5 100644 --- a/src/SplashDialog.h +++ b/src/SplashDialog.h @@ -37,7 +37,6 @@ private: void OnDontShow( wxCommandEvent & Evt ); HtmlWindow * mpHtml; - wxStaticBitmap* m_pIcon; wxBitmap* m_pLogo; //vvv static SplashDialog * pSelf; }; diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index 5295a8614..6145bc520 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -356,7 +356,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) S.StartStatic(_("Start Date and Time"), true); { m_pDatePickerCtrl_Start = - new wxDatePickerCtrl(this, // wxWindow *parent, + safenew wxDatePickerCtrl(this, // wxWindow *parent, ID_DATEPICKER_START, // wxWindowID id, m_DateTime_Start); // const wxDateTime& dt = wxDefaultDateTime, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, const wxValidator& validator = wxDefaultValidator, const wxString& name = "datectrl") @@ -378,7 +378,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) S.StartStatic(_("End Date and Time"), true); { m_pDatePickerCtrl_End = - new wxDatePickerCtrl(this, // wxWindow *parent, + safenew wxDatePickerCtrl(this, // wxWindow *parent, ID_DATEPICKER_END, // wxWindowID id, m_DateTime_End); // const wxDateTime& dt = wxDefaultDateTime, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDP_DEFAULT | wxDP_SHOWCENTURY, const wxValidator& validator = wxDefaultValidator, const wxString& name = "datectrl") diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 43b9167ef..fdbe9c225 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -9392,7 +9392,7 @@ void TrackPanel::OnSetFont(wxCommandEvent & WXUNUSED(event)) /* i18n-hint: (noun) The name of the typeface*/ S.AddPrompt(_("Face name")); - lb = new wxListBox(&dlg, wxID_ANY, + lb = safenew wxListBox(&dlg, wxID_ANY, wxDefaultPosition, wxDefaultSize, facenames, @@ -9404,7 +9404,7 @@ void TrackPanel::OnSetFont(wxCommandEvent & WXUNUSED(event)) /* i18n-hint: (noun) The size of the typeface*/ S.AddPrompt(_("Face size")); - sc = new wxSpinCtrl(&dlg, wxID_ANY, + sc = safenew wxSpinCtrl(&dlg, wxID_ANY, wxString::Format(wxT("%ld"), fontsize), wxDefaultPosition, wxDefaultSize, diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 7fac5d051..d6b0670ae 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -2855,7 +2855,8 @@ int EffectUIHost::ShowModal() #if defined(__WXMSW__) // Swap the Close and Apply buttons wxSizer *sz = mApplyBtn->GetContainingSizer(); - wxButton *apply = new wxButton(mApplyBtn->GetParent(), wxID_APPLY); + wxASSERT(mApplyBtn->GetParent()); // To justify safenew + wxButton *apply = safenew wxButton(mApplyBtn->GetParent(), wxID_APPLY); sz->Replace(mCloseBtn, apply); sz->Replace(mApplyBtn, mCloseBtn); sz->Layout(); @@ -2901,8 +2902,8 @@ bool EffectUIHost::Initialize() hs->Add(w, 1, wxEXPAND); vs->Add(hs, 1, wxEXPAND); - wxPanel *buttonPanel = new wxPanel(this, wxID_ANY); - wxPanel *bar = new wxPanel(buttonPanel, wxID_ANY); + wxPanel *buttonPanel = safenew wxPanel(this, wxID_ANY); + wxPanel *const bar = safenew wxPanel(buttonPanel, wxID_ANY); // This fools NVDA into not saying "Panel" when the dialog gets focus bar->SetName(wxT("\a")); @@ -2924,12 +2925,14 @@ bool EffectUIHost::Initialize() if (!mIsGUI) { - mMenuBtn = new wxButton(bar, kMenuID, _("&Manage")); + wxASSERT(bar); // To justify safenew + mMenuBtn = safenew wxButton(bar, kMenuID, _("&Manage")); bs->Add(mMenuBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); } else { - mMenuBtn = new wxBitmapButton(bar, kMenuID, CreateBitmap(effect_menu_xpm, true, false)); + wxASSERT(bar); // To justify safenew + mMenuBtn = safenew wxBitmapButton(bar, kMenuID, CreateBitmap(effect_menu_xpm, true, false)); #if defined(__WXMAC__) mMenuBtn->SetName(_("&Manage")); #else @@ -2947,13 +2950,15 @@ bool EffectUIHost::Initialize() { if (mSupportsRealtime) { - mPlayToggleBtn = new wxButton(bar, kPlayID, _("Start &Playback")); + wxASSERT(bar); // To justify safenew + mPlayToggleBtn = safenew wxButton(bar, kPlayID, _("Start &Playback")); mPlayToggleBtn->SetToolTip(_("Start and stop playback")); bs->Add(mPlayToggleBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); } else if (mEffect->GetType() != EffectTypeAnalyze) { - mPlayToggleBtn = new wxButton(bar, kPlayID, _("&Preview")); + wxASSERT(bar); // To justify safenew + mPlayToggleBtn = safenew wxButton(bar, kPlayID, _("&Preview")); mPlayToggleBtn->SetToolTip(_("Preview effect")); bs->Add(mPlayToggleBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); } @@ -2964,7 +2969,8 @@ bool EffectUIHost::Initialize() mPlayDisabledBM = CreateBitmap(effect_play_disabled_xpm, true, false); mStopBM = CreateBitmap(effect_stop_xpm, true, false); mStopDisabledBM = CreateBitmap(effect_stop_disabled_xpm, true, false); - bb = new wxBitmapButton(bar, kPlayID, mPlayBM); + wxASSERT(bar); // To justify safenew + bb = safenew wxBitmapButton(bar, kPlayID, mPlayBM); bb->SetBitmapDisabled(mPlayDisabledBM); mPlayBtn = bb; bs->Add(mPlayBtn); @@ -2983,12 +2989,14 @@ bool EffectUIHost::Initialize() { if (!mIsGUI) { - mRewindBtn = new wxButton(bar, kRewindID, _("Skip &Backward")); + wxASSERT(bar); // To justify safenew + mRewindBtn = safenew wxButton(bar, kRewindID, _("Skip &Backward")); bs->Add(mRewindBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); } else { - bb = new wxBitmapButton(bar, kRewindID, CreateBitmap(effect_rewind_xpm, true, true)); + wxASSERT(bar); // To justify safenew + bb = safenew wxBitmapButton(bar, kRewindID, CreateBitmap(effect_rewind_xpm, true, true)); bb->SetBitmapDisabled(CreateBitmap(effect_rewind_disabled_xpm, true, true)); mRewindBtn = bb; #if defined(__WXMAC__) @@ -3002,12 +3010,14 @@ bool EffectUIHost::Initialize() if (!mIsGUI) { - mFFwdBtn = new wxButton(bar, kFFwdID, _("Skip &Forward")); + wxASSERT(bar); // To justify safenew + mFFwdBtn = safenew wxButton(bar, kFFwdID, _("Skip &Forward")); bs->Add(mFFwdBtn, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); } else { - bb = new wxBitmapButton(bar, kFFwdID, CreateBitmap(effect_ffwd_xpm, true, true)); + wxASSERT(bar); // To justify safenew + bb = safenew wxBitmapButton(bar, kFFwdID, CreateBitmap(effect_ffwd_xpm, true, true)); bb->SetBitmapDisabled(CreateBitmap(effect_ffwd_disabled_xpm, true, true)); mFFwdBtn = bb; #if defined(__WXMAC__) @@ -3021,7 +3031,7 @@ bool EffectUIHost::Initialize() bs->Add(5, 5); - mEnableCb = new wxCheckBox(bar, kEnableID, _("&Enable")); + mEnableCb = safenew wxCheckBox(bar, kEnableID, _("&Enable")); mEnableCb->SetValue(mEnabled); mEnableCb->SetName(_("Enable")); bs->Add(mEnableCb, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, margin); diff --git a/src/effects/EffectRack.cpp b/src/effects/EffectRack.cpp index e53568130..2bdaf48b6 100644 --- a/src/effects/EffectRack.cpp +++ b/src/effects/EffectRack.cpp @@ -105,21 +105,22 @@ EffectRack::EffectRack() mRemoveRaised = CreateBitmap(remove_16x16_xpm, true, true); wxBoxSizer *bs = new wxBoxSizer(wxVERTICAL); - mPanel = new wxPanel(this, wxID_ANY); + mPanel = safenew wxPanel(this, wxID_ANY); bs->Add(mPanel, 1, wxEXPAND); SetSizer(bs); wxBoxSizer *hs = new wxBoxSizer(wxHORIZONTAL); - hs->Add(new wxButton(mPanel, wxID_APPLY, _("&Apply")), 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + wxASSERT(mPanel); // To justify safenew + hs->Add(safenew wxButton(mPanel, wxID_APPLY, _("&Apply")), 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); hs->AddStretchSpacer(); - mLatency = new wxStaticText(mPanel, wxID_ANY, _("Latency: 0")); + mLatency = safenew wxStaticText(mPanel, wxID_ANY, _("Latency: 0")); hs->Add(mLatency, 0, wxALIGN_CENTER); hs->AddStretchSpacer(); - hs->Add(new wxToggleButton(mPanel, wxID_CLEAR, _("&Bypass")), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + hs->Add(safenew wxToggleButton(mPanel, wxID_CLEAR, _("&Bypass")), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); bs = new wxBoxSizer(wxVERTICAL); bs->Add(hs, 0, wxEXPAND); - bs->Add(new wxStaticLine(mPanel, wxID_ANY), 0, wxEXPAND); + bs->Add(safenew wxStaticLine(mPanel, wxID_ANY), 0, wxEXPAND); mMainSizer = new wxFlexGridSizer(7); mMainSizer->AddGrowableCol(6); @@ -176,7 +177,8 @@ void EffectRack::Add(Effect *effect, bool active, bool favorite) wxBitmapButton *bb; - bb = new wxBitmapButton(mPanel, ID_POWER + mNumEffects, mPowerRaised); + wxASSERT(mPanel); // To justify safenew + bb = safenew wxBitmapButton(mPanel, ID_POWER + mNumEffects, mPowerRaised); bb->SetBitmapSelected(mPowerRaised); bb->SetName(_("Active State")); bb->SetToolTip(_("Set effect active state")); @@ -193,27 +195,27 @@ void EffectRack::Add(Effect *effect, bool active, bool favorite) } mMainSizer->Add(bb, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); - bb = new wxBitmapButton(mPanel, ID_EDITOR + mNumEffects, mSettingsRaised); + bb = safenew wxBitmapButton(mPanel, ID_EDITOR + mNumEffects, mSettingsRaised); bb->SetBitmapSelected(mSettingsPushed); bb->SetName(_("Show/Hide Editor")); bb->SetToolTip(_("Open/close effect editor")); mMainSizer->Add(bb, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); - bb = new wxBitmapButton(mPanel, ID_UP + mNumEffects, mUpRaised); + bb = safenew wxBitmapButton(mPanel, ID_UP + mNumEffects, mUpRaised); bb->SetBitmapSelected(mUpPushed); bb->SetBitmapDisabled(mUpDisabled); bb->SetName(_("Move Up")); bb->SetToolTip(_("Move effect up in the rack")); mMainSizer->Add(bb, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); - bb = new wxBitmapButton(mPanel, ID_DOWN + mNumEffects, mDownRaised); + bb = safenew wxBitmapButton(mPanel, ID_DOWN + mNumEffects, mDownRaised); bb->SetBitmapSelected(mDownPushed); bb->SetBitmapDisabled(mDownDisabled); bb->SetName(_("Move Down")); bb->SetToolTip(_("Move effect down in the rack")); mMainSizer->Add(bb, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); - bb = new wxBitmapButton(mPanel, ID_FAV + mNumEffects, mFavRaised); + bb = safenew wxBitmapButton(mPanel, ID_FAV + mNumEffects, mFavRaised); bb->SetBitmapSelected(mFavPushed); bb->SetName(_("Favorite")); bb->SetToolTip(_("Mark effect as a favorite")); @@ -230,13 +232,13 @@ void EffectRack::Add(Effect *effect, bool active, bool favorite) } mMainSizer->Add(bb, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); - bb = new wxBitmapButton(mPanel, ID_REMOVE + mNumEffects, mRemoveRaised); + bb = safenew wxBitmapButton(mPanel, ID_REMOVE + mNumEffects, mRemoveRaised); bb->SetBitmapSelected(mRemovePushed); bb->SetName(_("Remove")); bb->SetToolTip(_("Remove effect from the rack")); mMainSizer->Add(bb, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); - wxStaticText *text = new wxStaticText(mPanel, ID_NAME + mNumEffects, effect->GetName()); + wxStaticText *text = safenew wxStaticText(mPanel, ID_NAME + mNumEffects, effect->GetName()); text->SetToolTip(_("Name of the effect")); mMainSizer->Add(text, 0, wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5); diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 761c5e3ee..d8c5ac83d 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -719,12 +719,12 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) szrG = S.GetSizer(); // Panel used to host the sliders since they will be positioned manually. - mGraphicPanel = new wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(-1, 150)); + mGraphicPanel = safenew wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(-1, 150)); S.Prop(1).AddWindow(mGraphicPanel, wxEXPAND); for (int i = 0; (i < NUMBER_OF_BANDS) && (kThirdOct[i] <= mHiFreq); ++i) { - mSliders[i] = new wxSlider(mGraphicPanel, ID_Slider + i, 0, -20, +20, + mSliders[i] = safenew wxSlider(mGraphicPanel, ID_Slider + i, 0, -20, +20, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL | wxSL_INVERSE); mSliders[i]->Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(EffectEqualization::OnErase)); diff --git a/src/effects/ScoreAlignDialog.cpp b/src/effects/ScoreAlignDialog.cpp index 00047aca1..f0e3370a0 100644 --- a/src/effects/ScoreAlignDialog.cpp +++ b/src/effects/ScoreAlignDialog.cpp @@ -81,9 +81,9 @@ ScoreAlignDialog::ScoreAlignDialog(wxWindow *parent, ScoreAlignParams ¶ms) gPrefs->Read(wxT("/Tracks/Synchronize/SmoothTime"), &p.mSmoothTime, float(SA_DFT_SMOOTH_TIME)); - //wxButton *ok = new wxButton(this, wxID_OK, _("OK")); - //wxButton *cancel = new wxButton(this, wxID_CANCEL, _("Cancel")); - //wxSlider *sl = new wxSlider(this, ID_SLIDER, 0, 0, 100, + //wxButton *ok = safenew wxButton(this, wxID_OK, _("OK")); + //wxButton *cancel = safenew wxButton(this, wxID_CANCEL, _("Cancel")); + //wxSlider *sl = safenew wxSlider(this, ID_SLIDER, 0, 0, 100, // wxDefaultPosition, wxSize(20, 124), // wxSL_HORIZONTAL); @@ -178,7 +178,7 @@ ScoreAlignDialog::ScoreAlignDialog(wxWindow *parent, ScoreAlignParams ¶ms) S.EndMultiColumn(); S.EndStatic(); - mDefaultButton = new wxButton(this, ID_DEFAULT, _("Use Defaults")); + mDefaultButton = safenew wxButton(this, ID_DEFAULT, _("Use Defaults")); mDefaultButton->SetName(_("Restore Defaults")); S.AddStandardButtons(eOkButton | eCancelButton, mDefaultButton); diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 0614e0b5c..6164f2fef 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -2850,7 +2850,8 @@ void VSTEffect::BuildFancy() void VSTEffect::BuildPlain() { wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); - wxScrolledWindow *scroller = new wxScrolledWindow(mParent, + wxASSERT(mParent); // To justify safenew + wxScrolledWindow *const scroller = safenew wxScrolledWindow(mParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -2881,7 +2882,7 @@ void VSTEffect::BuildPlain() // Add the duration control for generators if (GetType() == EffectTypeGenerate) { - wxControl *item = new wxStaticText(scroller, 0, _("Duration:")); + wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mDuration = new NumericTextCtrl(NumericConverter::TIME, @@ -2924,7 +2925,7 @@ void VSTEffect::BuildPlain() for (int i = 0; i < mAEffect->numParams; i++) { - mNames[i] = new wxStaticText(scroller, + mNames[i] = safenew wxStaticText(scroller, wxID_ANY, wxEmptyString, wxDefaultPosition, @@ -2932,7 +2933,7 @@ void VSTEffect::BuildPlain() wxALIGN_RIGHT | wxST_NO_AUTORESIZE); gridSizer->Add(mNames[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - mSliders[i] = new wxSlider(scroller, + mSliders[i] = safenew wxSlider(scroller, ID_Sliders + i, 0, 0, @@ -2941,7 +2942,7 @@ void VSTEffect::BuildPlain() wxSize(200, -1)); gridSizer->Add(mSliders[i], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5); - mDisplays[i] = new wxStaticText(scroller, + mDisplays[i] = safenew wxStaticText(scroller, wxID_ANY, wxEmptyString, wxDefaultPosition, @@ -2949,7 +2950,7 @@ void VSTEffect::BuildPlain() wxALIGN_RIGHT | wxST_NO_AUTORESIZE); gridSizer->Add(mDisplays[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); - mLabels[i] = new wxStaticText(scroller, + mLabels[i] = safenew wxStaticText(scroller, wxID_ANY, wxEmptyString, wxDefaultPosition, diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index d7c9ae52f..b5fc8a3df 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -1754,7 +1754,8 @@ bool AudioUnitEffect::PopulateUI(wxWindow *parent) wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); - wxPanel *container = new wxPanel(mParent, wxID_ANY); + wxASSERT(mParent); // To justify safenew + wxPanel *container = safenew wxPanel(mParent, wxID_ANY); mainSizer->Add(container, 1, wxEXPAND); mParent->SetSizer(mainSizer); diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 642e83d17..282d2463a 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -1165,7 +1165,8 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) memset(mFields, 0, mData->PortCount * sizeof(wxTextCtrl *)); wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); - wxScrolledWindow *w = new wxScrolledWindow(mParent, + wxASSERT(mParent); // To justify safenew + wxScrolledWindow *const w = safenew wxScrolledWindow(mParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -1193,7 +1194,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) // Add the duration control for generators if (GetType() == EffectTypeGenerate) { - item = new wxStaticText(w, 0, _("Duration:")); + item = safenew wxStaticText(w, 0, _("Duration:")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); mDuration = new NumericTextCtrl(NumericConverter::TIME, @@ -1222,7 +1223,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) } wxString labelText = LAT1CTOWX(mData->PortNames[p]); - item = new wxStaticText(w, 0, labelText + wxT(":")); + item = safenew wxStaticText(w, 0, labelText + wxT(":")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); wxString fieldText; @@ -1230,7 +1231,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) if (LADSPA_IS_HINT_TOGGLED(hint.HintDescriptor)) { - mToggles[p] = new wxCheckBox(w, ID_Toggles + p, wxT("")); + mToggles[p] = safenew wxCheckBox(w, ID_Toggles + p, wxT("")); mToggles[p]->SetName(labelText); mToggles[p]->SetValue(mInputControls[p] > 0); gridSizer->Add(mToggles[p], 0, wxALL, 5); @@ -1285,7 +1286,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) // Don't specify a value at creation time. This prevents unwanted events // being sent to the OnTextCtrl() handler before the associated slider // has been created. - mFields[p] = new wxTextCtrl(w, ID_Texts + p); + mFields[p] = safenew wxTextCtrl(w, ID_Texts + p); mFields[p]->SetName(labelText); gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); @@ -1300,7 +1301,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) { str = Internat::ToDisplayString(lower); } - item = new wxStaticText(w, 0, str); + item = safenew wxStaticText(w, 0, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); } else @@ -1308,7 +1309,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) gridSizer->Add(1, 1, 0); } - mSliders[p] = new wxSlider(w, ID_Sliders + p, + mSliders[p] = safenew wxSlider(w, ID_Sliders + p, 0, 0, 1000, wxDefaultPosition, wxSize(200, -1)); @@ -1325,7 +1326,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) { str = Internat::ToDisplayString(upper); } - item = new wxStaticText(w, 0, str); + item = safenew wxStaticText(w, 0, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5); } else @@ -1394,7 +1395,7 @@ bool LadspaEffect::PopulateUI(wxWindow *parent) } wxString labelText = LAT1CTOWX(mData->PortNames[p]); - item = new wxStaticText(w, 0, labelText + wxT(":")); + item = safenew wxStaticText(w, 0, labelText + wxT(":")); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5); LADSPA_PortRangeHint hint = mData->PortRangeHints[p]; diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index 800185913..bef908fae 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -1454,7 +1454,7 @@ bool LV2Effect::BuildFancy() } // Use a panel to host the plugins GUI - mContainer = new wxPanel(mParent, wxID_ANY); + mContainer = safenew wxPanel(mParent, wxID_ANY); if (!mContainer) { lilv_uis_free(uis); @@ -1579,7 +1579,8 @@ bool LV2Effect::BuildPlain() mFields = new wxTextCtrl *[ctrlcnt]; wxSizer *outerSizer = new wxBoxSizer(wxVERTICAL); - wxScrolledWindow *w = new wxScrolledWindow(mParent, + wxASSERT(mParent); // To justify safenew + wxScrolledWindow *const w = safenew wxScrolledWindow(mParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, @@ -1601,7 +1602,7 @@ bool LV2Effect::BuildPlain() wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); - wxWindow *item = new wxStaticText(w, 0, _("&Duration:")); + wxWindow *item = safenew wxStaticText(w, 0, _("&Duration:")); sizer->Add(item, 0, wxALIGN_CENTER | wxALL, 5); mDuration = new NumericTextCtrl(NumericConverter::TIME, @@ -1650,7 +1651,8 @@ bool LV2Effect::BuildPlain() { gridSizer->Add(1, 1, 0); - wxButton *b = new wxButton(w, ID_Triggers + p, labelText); + wxASSERT(w); // To justify safenew + wxButton *b = safenew wxButton(w, ID_Triggers + p, labelText); gridSizer->Add(b, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); gridSizer->Add(1, 1, 0); @@ -1659,14 +1661,14 @@ bool LV2Effect::BuildPlain() continue; } - wxWindow *item = new wxStaticText(w, wxID_ANY, labelText + wxT(":"), + wxWindow *item = safenew wxStaticText(w, wxID_ANY, labelText + wxT(":"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT); if (ctrl.mToggle) { - wxCheckBox *c = new wxCheckBox(w, ID_Toggles + p, wxT("")); + wxCheckBox *c = safenew wxCheckBox(w, ID_Toggles + p, wxT("")); c->SetName(labelText); c->SetValue(ctrl.mVal > 0); gridSizer->Add(c, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); @@ -1691,7 +1693,7 @@ bool LV2Effect::BuildPlain() s = 0; } - wxChoice *c = new wxChoice(w, ID_Choices + p); + wxChoice *c = safenew wxChoice(w, ID_Choices + p); c->SetName(labelText); c->Append(ctrl.mScaleLabels); c->SetSelection(s); @@ -1711,7 +1713,7 @@ bool LV2Effect::BuildPlain() } else { - mFields[p] = new wxTextCtrl(w, ID_Texts + p, wxT("")); + mFields[p] = safenew wxTextCtrl(w, ID_Texts + p, wxT("")); mFields[p]->SetName(labelText); gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); @@ -1754,7 +1756,7 @@ bool LV2Effect::BuildPlain() { str = Internat::ToDisplayString(ctrl.mLo); } - item = new wxStaticText(w, wxID_ANY, str); + item = safenew wxStaticText(w, wxID_ANY, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT); } else @@ -1762,7 +1764,7 @@ bool LV2Effect::BuildPlain() gridSizer->Add(1, 1, 0); } - mSliders[p] = new wxSlider(w, ID_Sliders + p, + mSliders[p] = safenew wxSlider(w, ID_Sliders + p, 0, 0, 1000, wxDefaultPosition, wxSize(150, -1)); @@ -1780,7 +1782,7 @@ bool LV2Effect::BuildPlain() { str = Internat::ToDisplayString(ctrl.mHi); } - item = new wxStaticText(w, wxID_ANY, str); + item = safenew wxStaticText(w, wxID_ANY, str); gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT); } else diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 3e4dd3911..95fe3c21d 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -2247,13 +2247,13 @@ NyquistOutputDialog::NyquistOutputDialog(wxWindow * parent, wxWindowID id, wxButton *button; wxControl *item; - item = new wxStaticText(this, -1, prompt); + item = safenew wxStaticText(this, -1, prompt); item->SetName(prompt); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) mainSizer->Add(item, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxRIGHT, 10); // TODO use ShowInfoDialog() instead. // Beware this dialog MUST work with screen readers. - item = new wxTextCtrl(this, -1, message, + item = safenew wxTextCtrl(this, -1, message, wxDefaultPosition, wxSize(400, 200), wxTE_MULTILINE | wxTE_READONLY); mainSizer->Add(item, 0, wxALIGN_LEFT | wxALL, 10); @@ -2261,7 +2261,7 @@ NyquistOutputDialog::NyquistOutputDialog(wxWindow * parent, wxWindowID id, hSizer = new wxBoxSizer(wxHORIZONTAL); /* i18n-hint: In most languages OK is to be translated as OK. It appears on a button.*/ - button = new wxButton(this, wxID_OK, _("OK")); + button = safenew wxButton(this, wxID_OK, _("OK")); button->SetDefault(); hSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5); diff --git a/src/export/Export.cpp b/src/export/Export.cpp index eba071971..87b810a27 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -225,7 +225,8 @@ bool ExportPlugin::DisplayOptions(wxWindow * WXUNUSED(parent), int WXUNUSED(form wxWindow *ExportPlugin::OptionsCreate(wxWindow *parent, int WXUNUSED(format)) { - wxPanel *p = new wxPanel(parent, wxID_ANY); + wxASSERT(parent); // To justify safenew + wxPanel *p = safenew wxPanel(parent, wxID_ANY); ShuttleGui S(p, eIsCreatingFromPrefs); S.StartHorizontalLay(wxCENTER); @@ -881,7 +882,7 @@ void Exporter::CreateUserPane(wxWindow *parent) { S.StartStatic(_("Format Options"), 1); { - mBook = new wxSimplebook(parent); + mBook = safenew wxSimplebook(S.GetParent()); S.AddWindow(mBook, wxEXPAND); for (size_t i = 0; i < mPlugins.GetCount(); i++) @@ -1224,10 +1225,10 @@ ExportMixerDialog::ExportMixerDialog( TrackList *tracks, bool selectedOnly, wxString label; label.Printf( _( "Output Channels: %2d" ), mMixerSpec->GetNumChannels() ); - mChannelsText = new wxStaticText( this, -1, label); + mChannelsText = safenew wxStaticText(this, -1, label); horSizer->Add( mChannelsText, 0, wxALIGN_LEFT | wxALL, 5 ); - wxSlider *channels = new wxSlider( this, ID_SLIDER_CHANNEL, + wxSlider *channels = safenew wxSlider( this, ID_SLIDER_CHANNEL, mMixerSpec->GetNumChannels(), 1, mMixerSpec->GetMaxNumChannels(), wxDefaultPosition, wxSize( 300, -1 ) ); channels->SetName(label); diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index 74219bcc5..d05f6a266 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -270,7 +270,7 @@ void ExportMultiple::PopulateOrExchange(ShuttleGui& S) S.AddPrompt(_("Options:")); if (!mBook) { - mBook = new wxSimplebook(S.GetParent(), OptionsID, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC); + mBook = safenew wxSimplebook(S.GetParent(), OptionsID, wxDefaultPosition, wxDefaultSize, wxBORDER_STATIC); for (size_t i = 0; i < mPlugins.GetCount(); i++) { for (int j = 0; j < mPlugins[i]->GetFormatCount(); j++) diff --git a/src/import/Import.cpp b/src/import/Import.cpp index dbb8ba1d1..2e8eac3bf 100644 --- a/src/import/Import.cpp +++ b/src/import/Import.cpp @@ -755,7 +755,7 @@ wxDialog( parent, id, title, position, size, style | wxRESIZE_BORDER ) wxBoxSizer *vertSizer = new wxBoxSizer( wxVERTICAL ); wxArrayString *choices = mFile->GetStreamInfo(); - StreamList = new wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, *choices , wxLB_EXTENDED | wxLB_ALWAYS_SB); + StreamList = safenew wxListBox(this, -1, wxDefaultPosition, wxDefaultSize, *choices , wxLB_EXTENDED | wxLB_ALWAYS_SB); vertSizer->Add( StreamList, 1, wxEXPAND | wxALIGN_LEFT | wxALL, 5 ); diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index 34df7e035..1a8b4b220 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -243,7 +243,7 @@ static wxString AskCopyOrEdit() wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL); dialog.SetSizer(vbox); - wxStaticText *message = new wxStaticText(&dialog, -1, wxString::Format(_("\ + wxStaticText *message = safenew wxStaticText(&dialog, -1, wxString::Format(_("\ When importing uncompressed audio files you can either copy them \ into the project, or read them directly from their current location (without copying).\n\n\ Your current preference is set to %s.\n\n\ @@ -259,19 +259,19 @@ How do you want to import the current file(s)?"), oldCopyPref == wxT("copy") ? _ vbox->Add(message, 1, wxALL | wxEXPAND, 10); - wxStaticBox *box = new wxStaticBox(&dialog, -1, _("Choose an import method")); + wxStaticBox *box = safenew wxStaticBox(&dialog, -1, _("Choose an import method")); box->SetName(box->GetLabel()); wxStaticBoxSizer *boxsizer = new wxStaticBoxSizer(box, wxVERTICAL); - wxRadioButton *copyRadio = new wxRadioButton(&dialog, -1, _("Make a © of the files before editing (safer)"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); + wxRadioButton *copyRadio = safenew wxRadioButton(&dialog, -1, _("Make a © of the files before editing (safer)"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); boxsizer->Add(copyRadio, 0, wxALL); copyRadio->SetName(wxStripMenuCodes(copyRadio->GetLabel())); - wxRadioButton *aliasRadio = new wxRadioButton(&dialog, -1, _("Read the files &directly from the original (faster)")); + wxRadioButton *aliasRadio = safenew wxRadioButton(&dialog, -1, _("Read the files &directly from the original (faster)")); boxsizer->Add(aliasRadio, 0, wxALL); aliasRadio->SetName(wxStripMenuCodes(aliasRadio->GetLabel())); - wxCheckBox *dontAskNextTimeBox = new wxCheckBox(&dialog, -1, _("Don't &warn again and always use my choice above")); + wxCheckBox *dontAskNextTimeBox = safenew wxCheckBox(&dialog, -1, _("Don't &warn again and always use my choice above")); boxsizer->Add(dontAskNextTimeBox, 0, wxALL); vbox->Add(boxsizer, 0, wxALL, 10); dontAskNextTimeBox->SetName(wxStripMenuCodes(dontAskNextTimeBox->GetLabel())); diff --git a/src/prefs/KeyConfigPrefs.cpp b/src/prefs/KeyConfigPrefs.cpp index 315c4e546..e6524f62d 100644 --- a/src/prefs/KeyConfigPrefs.cpp +++ b/src/prefs/KeyConfigPrefs.cpp @@ -200,7 +200,7 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S) mFilterLabel = S.AddVariableText(_("Searc&h:")); if (!mFilter) { - mFilter = new wxTextCtrl(this, + mFilter = safenew wxTextCtrl(this, FilterID, wxT(""), wxDefaultPosition, @@ -241,7 +241,7 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S) S.StartThreeColumn(); { if (!mKey) { - mKey = new wxTextCtrl(this, + mKey = safenew wxTextCtrl(this, CurrentComboID, wxT(""), wxDefaultPosition, @@ -769,7 +769,7 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S) S.StartThreeColumn(); { if (!mKey) { - mKey = new wxTextCtrl(this, + mKey = safenew wxTextCtrl(this, CurrentComboID, wxT(""), wxDefaultPosition, diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index 9b060ce16..c7749ecb0 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -217,7 +217,7 @@ PrefsDialog::PrefsDialog { wxASSERT(factories.size() > 0); if (!uniquePage) { - mCategories = new wxTreebookExt(this, wxID_ANY, mTitlePrefix); + mCategories = safenew wxTreebookExt(this, wxID_ANY, mTitlePrefix); S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, true); { S.Prop(1); diff --git a/src/toolbars/DeviceToolBar.cpp b/src/toolbars/DeviceToolBar.cpp index 298dce9ae..c6e351e8c 100644 --- a/src/toolbars/DeviceToolBar.cpp +++ b/src/toolbars/DeviceToolBar.cpp @@ -93,7 +93,7 @@ void DeviceToolBar::Populate() { DeinitChildren(); // Hosts - mHost = new wxChoice(this, + mHost = safenew wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); @@ -104,17 +104,17 @@ void DeviceToolBar::Populate() if( mRecordBitmap == NULL ) mRecordBitmap = new wxBitmap(theTheme.Bitmap(bmpMic)); - Add(new wxStaticBitmap(this, + Add(safenew wxStaticBitmap(this, wxID_ANY, *mRecordBitmap), 0, wxALIGN_CENTER); - mInput = new wxChoice(this, + mInput = safenew wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); Add(mInput, 0, wxALIGN_CENTER); - mInputChannels = new wxChoice(this, + mInputChannels = safenew wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); @@ -123,11 +123,11 @@ void DeviceToolBar::Populate() // Output device if( mPlayBitmap == NULL ) mPlayBitmap = new wxBitmap(theTheme.Bitmap(bmpSpeaker)); - Add(new wxStaticBitmap(this, + Add(safenew wxStaticBitmap(this, wxID_ANY, *mPlayBitmap), 0, wxALIGN_CENTER); - mOutput = new wxChoice(this, + mOutput = safenew wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize); diff --git a/src/toolbars/MixerToolBar.cpp b/src/toolbars/MixerToolBar.cpp index 9d59add4d..18616b6eb 100644 --- a/src/toolbars/MixerToolBar.cpp +++ b/src/toolbars/MixerToolBar.cpp @@ -80,7 +80,7 @@ void MixerToolBar::Populate() if( mRecordBitmap == NULL ) mRecordBitmap = new wxBitmap(theTheme.Bitmap(bmpMic)); - Add(new wxStaticBitmap(this, + Add(safenew wxStaticBitmap(this, wxID_ANY, *mRecordBitmap), 0, wxALIGN_CENTER); @@ -93,7 +93,7 @@ void MixerToolBar::Populate() if( mPlayBitmap == NULL ) mPlayBitmap = new wxBitmap(theTheme.Bitmap(bmpSpeaker)); - Add(new wxStaticBitmap(this, + Add(safenew wxStaticBitmap(this, wxID_ANY, *mPlayBitmap), 0, wxALIGN_CENTER); diff --git a/src/toolbars/SelectionBar.cpp b/src/toolbars/SelectionBar.cpp index 76b431d33..933d22c33 100644 --- a/src/toolbars/SelectionBar.cpp +++ b/src/toolbars/SelectionBar.cpp @@ -129,7 +129,7 @@ void SelectionBar::Populate() // Top row (mostly labels) // - mainSizer->Add(new wxStaticText(this, -1, _("Project Rate (Hz):"), + mainSizer->Add(safenew wxStaticText(this, -1, _("Project Rate (Hz):"), // LLL: On my Ubuntu 7.04 install, the label wraps to two lines // and I could not figure out why. Thus...hackage. #if defined(__WXGTK__) @@ -141,24 +141,24 @@ void SelectionBar::Populate() mainSizer->Add(5, 1); - mainSizer->Add(new wxStaticText(this, -1, _("Snap To:")), + mainSizer->Add(safenew wxStaticText(this, -1, _("Snap To:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); - mainSizer->Add(new wxStaticText(this, -1, _("Selection Start:")), + mainSizer->Add(safenew wxStaticText(this, -1, _("Selection Start:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); bool showSelectionLength = false; gPrefs->Read(wxT("/ShowSelectionLength"), &showSelectionLength); hSizer = new wxBoxSizer(wxHORIZONTAL); - mRightEndButton = new wxRadioButton(this, OnEndRadioID, _("End"), + mRightEndButton = safenew wxRadioButton(this, OnEndRadioID, _("End"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); mRightEndButton->SetName(_("End")); mRightEndButton->SetValue(!showSelectionLength); hSizer->Add(mRightEndButton, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5); - mRightLengthButton = new wxRadioButton(this, OnLengthRadioID, _("Length")); + mRightLengthButton = safenew wxRadioButton(this, OnLengthRadioID, _("Length")); mRightLengthButton->SetName(_("Length")); mRightLengthButton->SetValue(showSelectionLength); hSizer->Add(mRightLengthButton, @@ -169,7 +169,7 @@ void SelectionBar::Populate() // so it's probably been fixed. But, it doesn't hurt to have this // in for all versions. wxRadioButton* dummyButton = - new wxRadioButton(this, wxID_ANY, _("hidden"), + safenew wxRadioButton(this, wxID_ANY, _("hidden"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); dummyButton->Disable(); @@ -179,14 +179,14 @@ void SelectionBar::Populate() mainSizer->Add(5, 1); - mainSizer->Add(new wxStaticText(this, -1, _("Audio Position:")), + mainSizer->Add(safenew wxStaticText(this, -1, _("Audio Position:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 0); // // Middle row (mostly time controls) // - mRateBox = new wxComboBox(this, OnRateID, + mRateBox = safenew wxComboBox(this, OnRateID, wxT(""), wxDefaultPosition, wxSize(80, -1)); mRateBox->SetName(_("Project Rate (Hz):")); @@ -226,12 +226,12 @@ void SelectionBar::Populate() mainSizer->Add(mRateBox, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); - mainSizer->Add(new wxStaticLine(this, -1, wxDefaultPosition, + mainSizer->Add(safenew wxStaticLine(this, -1, wxDefaultPosition, wxSize(1, toolbarSingle), wxLI_VERTICAL), 0, wxRIGHT, 5); - mSnapTo = new wxChoice(this, OnSnapToID, + mSnapTo = safenew wxChoice(this, OnSnapToID, wxDefaultPosition, wxDefaultSize, SnapManager::GetSnapLabels()); mainSizer->Add(mSnapTo, @@ -265,7 +265,7 @@ void SelectionBar::Populate() mRightTime->EnableMenu(); mainSizer->Add(mRightTime, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); - mainSizer->Add(new wxStaticLine(this, -1, wxDefaultPosition, + mainSizer->Add(safenew wxStaticLine(this, -1, wxDefaultPosition, wxSize(1, toolbarSingle), wxLI_VERTICAL), 0, wxRIGHT, 5); diff --git a/src/toolbars/SpectralSelectionBar.cpp b/src/toolbars/SpectralSelectionBar.cpp index 424eafc12..75baa1d2b 100644 --- a/src/toolbars/SpectralSelectionBar.cpp +++ b/src/toolbars/SpectralSelectionBar.cpp @@ -134,7 +134,7 @@ void SpectralSelectionBar::Populate() _("Center frequency and Width"), _("Low and High Frequencies"), }; - mChoice = new wxChoice + mChoice = safenew wxChoice (this, OnChoiceID, wxDefaultPosition, wxDefaultSize, 2, choices, 0, wxDefaultValidator, _("Spectral Selection")); mChoice->SetSelection(mbCenterAndWidth ? 0 : 1); diff --git a/src/toolbars/TranscriptionToolBar.cpp b/src/toolbars/TranscriptionToolBar.cpp index 58338a6ad..6f800f593 100644 --- a/src/toolbars/TranscriptionToolBar.cpp +++ b/src/toolbars/TranscriptionToolBar.cpp @@ -255,7 +255,7 @@ void TranscriptionToolBar::Populate() TRANSLATABLE("Direction Changes (High Threshold)") }; - mKeyTypeChoice = new wxChoice(this, TTB_KeyType, + mKeyTypeChoice = safenew wxChoice(this, TTB_KeyType, wxDefaultPosition, wxDefaultSize, 5, diff --git a/src/widgets/ErrorDialog.cpp b/src/widgets/ErrorDialog.cpp index b9810b75b..8bf5ef118 100644 --- a/src/widgets/ErrorDialog.cpp +++ b/src/widgets/ErrorDialog.cpp @@ -114,13 +114,13 @@ ErrorDialog::ErrorDialog( wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL); - wxStaticText *statText = new wxStaticText(this, -1, message); + wxStaticText *statText = safenew wxStaticText(this, -1, message); mainSizer->Add(statText, 0, wxALIGN_LEFT|wxALL, 5); - wxButton *help = new wxButton(this, wxID_HELP, _("Help")); + wxButton *help = safenew wxButton(this, wxID_HELP, _("Help")); hSizer->Add(help, 0, wxALIGN_LEFT|wxALL, 5); - wxButton *ok = new wxButton(this, wxID_OK, _("OK")); + wxButton *ok = safenew wxButton(this, wxID_OK, _("OK")); ok->SetDefault(); ok->SetFocus(); hSizer->Add(ok, 0, wxALIGN_RIGHT|wxALL, 5); diff --git a/src/widgets/ExpandingToolBar.cpp b/src/widgets/ExpandingToolBar.cpp index cd7431752..8ef806004 100644 --- a/src/widgets/ExpandingToolBar.cpp +++ b/src/widgets/ExpandingToolBar.cpp @@ -135,9 +135,9 @@ ExpandingToolBar::ExpandingToolBar(wxWindow* parent, mDragImage(NULL), mTopLevelParent(NULL) { - mMainPanel = new wxPanel(this, -1, + mMainPanel = safenew wxPanel(this, -1, wxDefaultPosition, wxSize(1, 1)); - mExtraPanel = new wxPanel(this, -1, + mExtraPanel = safenew wxPanel(this, -1, wxDefaultPosition, wxSize(1, 1)); mGrabber = NULL; diff --git a/src/widgets/Grid.cpp b/src/widgets/Grid.cpp index a34ae0633..bfadd8d5d 100644 --- a/src/widgets/Grid.cpp +++ b/src/widgets/Grid.cpp @@ -278,7 +278,7 @@ wxGridCellEditor *ChoiceEditor::Clone() const void ChoiceEditor::Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler) { - m_control = new wxChoice(parent, + m_control = safenew wxChoice(parent, id, wxDefaultPosition, wxDefaultSize, diff --git a/src/widgets/HelpSystem.cpp b/src/widgets/HelpSystem.cpp index 989f3d22c..be9f31673 100644 --- a/src/widgets/HelpSystem.cpp +++ b/src/widgets/HelpSystem.cpp @@ -78,7 +78,7 @@ void HelpSystem::ShowInfoDialog( wxWindow *parent, S.EndHorizontalLay(); // Next three lines add a tiny dragger. - wxStatusBar * pBar = new wxStatusBar( &dlog ); + wxStatusBar * pBar = safenew wxStatusBar( &dlog ); pBar->SetSize( 18, 38); S.AddWindow( pBar, wxALIGN_BOTTOM|wxALIGN_RIGHT ); @@ -135,7 +135,7 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent, } S.EndHorizontalLay(); - html = new LinkingHtmlWindow(pPan, wxID_ANY, + html = safenew LinkingHtmlWindow(pPan, wxID_ANY, wxDefaultPosition, bIsFile ? wxSize(500, 400) : wxSize(480, 240), wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER); diff --git a/src/widgets/MultiDialog.cpp b/src/widgets/MultiDialog.cpp index 5f94113c7..a1dc12e53 100644 --- a/src/widgets/MultiDialog.cpp +++ b/src/widgets/MultiDialog.cpp @@ -74,10 +74,10 @@ MultiDialog::MultiDialog(wxWindow * pParent, wxBitmap bitmap = wxArtProvider::GetIcon(wxART_WARNING, wxART_MESSAGE_BOX); - wxStaticBitmap *icon = new wxStaticBitmap(this, -1, bitmap); + wxStaticBitmap *icon = safenew wxStaticBitmap(this, -1, bitmap); iconAndTextSizer->Add( icon, 0, wxCENTER ); - wxStaticText *statText = new wxStaticText(this, -1, message); + wxStaticText *statText = safenew wxStaticText(this, -1, message); statText->SetName(message); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) iconAndTextSizer->Add(statText, 1, wxCENTER|wxLEFT,15 ); @@ -94,7 +94,7 @@ MultiDialog::MultiDialog(wxWindow * pParent, count++; } - mRadioBox = new wxRadioBox(this,-1, + mRadioBox = safenew wxRadioBox(this,-1, boxMsg, wxDefaultPosition, wxDefaultSize, count, buttonLabels, @@ -109,14 +109,14 @@ MultiDialog::MultiDialog(wxWindow * pParent, wxButton* pButton; if(log) { - pButton = new wxButton(this, ID_SHOW_LOG_BUTTON, _("Show Log for Details")); + pButton = safenew wxButton(this, ID_SHOW_LOG_BUTTON, _("Show Log for Details")); buttonSizer->Add(pButton, 0, wxALIGN_LEFT | wxALL, 5); pButton->SetDefault(); // Encourage user to look at files. buttonSizer->AddSpacer(40); } - pButton = new wxButton(this, wxID_OK, _("OK")); + pButton = safenew wxButton(this, wxID_OK, _("OK")); if(!log) pButton->SetDefault(); buttonSizer->Add(pButton, 0, wxALIGN_RIGHT | wxALL, 5); diff --git a/src/widgets/ProgressDialog.cpp b/src/widgets/ProgressDialog.cpp index baa4af55d..c3ee2e154 100644 --- a/src/widgets/ProgressDialog.cpp +++ b/src/widgets/ProgressDialog.cpp @@ -1095,7 +1095,7 @@ bool ProgressDialog::Create(const wxString & title, v = new wxBoxSizer(wxVERTICAL); - mMessage = new wxStaticText(this, + mMessage = safenew wxStaticText(this, wxID_ANY, message, wxDefaultPosition, @@ -1108,7 +1108,7 @@ bool ProgressDialog::Create(const wxString & title, // // // - mGauge = new wxGauge(this, + mGauge = safenew wxGauge(this, wxID_ANY, 1000, wxDefaultPosition, @@ -1122,7 +1122,7 @@ bool ProgressDialog::Create(const wxString & title, // wxFlexGridSizer *g = new wxFlexGridSizer(2, 2, 10, 10); - w = new wxStaticText(this, + w = safenew wxStaticText(this, wxID_ANY, _("Elapsed Time:"), wxDefaultPosition, @@ -1131,7 +1131,7 @@ bool ProgressDialog::Create(const wxString & title, w->SetName(w->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) g->Add(w, 0, wxALIGN_RIGHT); - mElapsed = new wxStaticText(this, + mElapsed = safenew wxStaticText(this, wxID_ANY, wxT("00:00:00"), wxDefaultPosition, @@ -1144,7 +1144,7 @@ bool ProgressDialog::Create(const wxString & title, // // // - w = new wxStaticText(this, + w = safenew wxStaticText(this, wxID_ANY, _("Remaining Time:"), wxDefaultPosition, @@ -1153,7 +1153,7 @@ bool ProgressDialog::Create(const wxString & title, w->SetName(w->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) g->Add(w, 0, wxALIGN_RIGHT); - mRemaining = new wxStaticText(this, + mRemaining = safenew wxStaticText(this, wxID_ANY, wxT("00:00:00"), wxDefaultPosition, @@ -1169,13 +1169,13 @@ bool ProgressDialog::Create(const wxString & title, if (!(flags & pdlgHideStopButton)) { - w = new wxButton(this, wxID_OK, _("Stop")); + w = safenew wxButton(this, wxID_OK, _("Stop")); h->Add(w, 0, wxRIGHT, 10); } if (!(flags & pdlgHideCancelButton)) { - w = new wxButton(this, wxID_CANCEL, _("Cancel")); + w = safenew wxButton(this, wxID_CANCEL, _("Cancel")); h->Add(w, 0, wxRIGHT, 10); }