From a52f7f8410ff65b6088f8cd756af1d0ef9468429 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 8 Aug 2016 09:50:55 -0400 Subject: [PATCH 1/3] new -> NEW in comments, so text search for naked new excludes them --- src/AudioIO.cpp | 2 +- src/AudioIO.h | 2 +- src/NoteTrack.cpp | 4 ++-- src/Project.cpp | 2 +- src/Project.h | 2 +- src/TimerRecordDialog.cpp | 2 +- src/Track.h | 4 ++-- src/TrackPanel.cpp | 4 ++-- src/TrackPanelCell.h | 2 +- src/UndoManager.cpp | 2 +- src/effects/Equalization.cpp | 6 +++--- src/effects/Equalization.h | 2 +- src/toolbars/ToolDock.cpp | 6 +++--- src/widgets/Ruler.cpp | 2 +- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/AudioIO.cpp b/src/AudioIO.cpp index d1d46329d..5194eb5f8 100644 --- a/src/AudioIO.cpp +++ b/src/AudioIO.cpp @@ -522,7 +522,7 @@ struct AudioIO::ScrubQueue mDebt += deficit; auto toDiscard = mDebt - mMaxDebt; while (toDiscard > 0 && mMiddleIdx != mLeadingIdx) { - // Cancel some debt (discard some new work) + // Cancel some debt (discard some NEW work) auto &entry = mEntries[mMiddleIdx]; auto &dur = entry.mDuration; if (toDiscard >= dur) { diff --git a/src/AudioIO.h b/src/AudioIO.h index 91a166557..007f47f83 100644 --- a/src/AudioIO.h +++ b/src/AudioIO.h @@ -164,7 +164,7 @@ class AUDACITY_DLL_API AudioIO final { #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT bool IsScrubbing() { return IsBusy() && mScrubQueue != 0; } - /** \brief enqueue a NEW scrub play interval, using the last end as the new start, + /** \brief enqueue a NEW scrub play interval, using the last end as the NEW start, * to be played over the same duration, as between this and the last * enqueuing (or the starting of the stream). Except, we do not exceed maximum * scrub speed, so may need to adjust either the start or the end. diff --git a/src/NoteTrack.cpp b/src/NoteTrack.cpp index 4082a4b85..74ba20476 100644 --- a/src/NoteTrack.cpp +++ b/src/NoteTrack.cpp @@ -547,7 +547,7 @@ bool NoteTrack::Shift(double t) // t is always seconds int m = ROUND(t * tempo / beats_per_measure); // need at least 1 measure, so if we rounded down to zero, fix it if (m == 0) m = 1; - // compute NEW tempo so that m measures at new tempo take t seconds + // compute NEW tempo so that m measures at NEW tempo take t seconds tempo = beats_per_measure * m / t; // in beats per second mSeq->insert_silence(0.0, beats_per_measure * m); mSeq->set_tempo(tempo * 60.0 /* bpm */, 0.0, beats_per_measure * m); @@ -704,7 +704,7 @@ Alg_seq *NoteTrack::MakeExportableSeq(std::unique_ptr &cleanup) // beat double bar = tsp->beat + beats_per_measure * (int(measures) + 1); double bar_offset = bar - beat; - // insert NEW time signature at bar_offset in new sequence + // insert NEW time signature at bar_offset in NEW sequence // It will have the same time signature, but the position will // force a barline to match the barlines in mSeq seq->set_time_sig(bar_offset, tsp->num, tsp->den); diff --git a/src/Project.cpp b/src/Project.cpp index d092c75d3..793e0d8c8 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -5344,7 +5344,7 @@ bool AudacityProject::IsProjectSaved() { } bool AudacityProject::SaveFromTimerRecording(wxFileName fnFile) { - // MY: Will save the project to a new location a-la Save As + // MY: Will save the project to a NEW location a-la Save As // and then tidy up after itself. wxString sNewFileName = fnFile.GetFullPath(); diff --git a/src/Project.h b/src/Project.h index 5b4beb869..8f810295c 100644 --- a/src/Project.h +++ b/src/Project.h @@ -551,7 +551,7 @@ public: // Tags (artist name, song properties, MP3 ID3 info, etc.) // The structure may be shared with undo history entries - // To keep undo working correctly, always replace this with a new duplicate + // To keep undo working correctly, always replace this with a NEW duplicate // BEFORE doing any editing of it! std::shared_ptr mTags; diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index 8d8d585d6..ff0579959 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -85,7 +85,7 @@ static double wxDateTime_to_AudacityTime(wxDateTime& dateTime) // By default the msaa state of wxDatePickerCtrl is always normal (0x0), and this causes nvda not // to read the control when the user tabs to it. This class // modifies the state to be focusable + focused (when it's the focus). -// Note that even with this class NVDA still doesn't read the new selected part of the control when left/right +// Note that even with this class NVDA still doesn't read the NEW selected part of the control when left/right // arrow keys are used. #if wxUSE_ACCESSIBILITY diff --git a/src/Track.h b/src/Track.h index e5f0e8084..5e1ed41fd 100644 --- a/src/Track.h +++ b/src/Track.h @@ -212,10 +212,10 @@ class AUDACITY_DLL_API Track /* not final */ : public XMLTagHandler // separate from the Track. DirManager* GetDirManager() const { return mDirManager; } - // Create a new track and modify this track (or return null for failure) + // Create a NEW track and modify this track (or return null for failure) virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1)) { return{}; } - // Create a new track and don't modify this track (or return null for failure) + // Create a NEW track and don't modify this track (or return null for failure) virtual Holder Copy(double WXUNUSED(t0), double WXUNUSED(t1)) const { return{}; } // Return true for success diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index e04c01ae6..14f62dc80 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -146,7 +146,7 @@ is time to refresh some aspect of the screen. Stereo channel grouping. The precise names of the classes are subject to revision. - Have deliberately not created NEW files for the new classes + Have deliberately not created NEW files for the NEW classes such as AdornedRulerPanel and TrackInfo - yet. *//*****************************************************************/ @@ -1091,7 +1091,7 @@ void TrackPanel::OnPaint(wxPaintEvent & /* event */) // Drawing now goes directly to the client area. // DrawOverlays() may need to draw outside the clipped region. - // (Used to make a new, separate wxClientDC, but that risks flashing + // (Used to make a NEW, separate wxClientDC, but that risks flashing // problems on Mac.) dc.DestroyClippingRegion(); DrawOverlays(true, &dc); diff --git a/src/TrackPanelCell.h b/src/TrackPanelCell.h index ca5adcde1..6daaa593b 100644 --- a/src/TrackPanelCell.h +++ b/src/TrackPanelCell.h @@ -11,7 +11,7 @@ Paul Licameli #ifndef __AUDACITY_TRACK_PANEL_CELL__ #define __AUDACITY_TRACK_PANEL_CELL__ -// Future: TrackPanelCell will be generalized to a new abstract base class of Track +// Future: TrackPanelCell will be generalized to a NEW abstract base class of Track // and of other things. class Track; using TrackPanelCell = Track; diff --git a/src/UndoManager.cpp b/src/UndoManager.cpp index 92f81aa7e..19ef54e70 100644 --- a/src/UndoManager.cpp +++ b/src/UndoManager.cpp @@ -265,7 +265,7 @@ void UndoManager::PushState(const TrackList * l, } // Assume tags was duplicted before any changes. - // Just save a new shared_ptr to it. + // Just save a NEW shared_ptr to it. stack.push_back( make_movable (std::move(tracksCopy), diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 3267eff88..1cca30bf7 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -143,7 +143,7 @@ enum kInterpolations // Increment whenever EQCurves.xml is updated #define EQCURVES_VERSION 1 #define EQCURVES_REVISION 0 -#define UPDATE_ALL 0 // 0 = merge new presets only, 1 = Update all factory presets. +#define UPDATE_ALL 0 // 0 = merge NEW presets only, 1 = Update all factory presets. static const wxString kInterpStrings[kNumInterpolations] = { @@ -1370,7 +1370,7 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append) bool needUpdate = (eqCurvesCurrentVersion != eqCurvesInstalledVersion); - // UpdateDefaultCurves allows us to import new factory presets only, + // UpdateDefaultCurves allows us to import NEW factory presets only, // or update all factory preset curves. if (needUpdate) UpdateDefaultCurves( UPDATE_ALL != 0 ); @@ -1506,7 +1506,7 @@ void EffectEqualization::UpdateDefaultCurves(bool updateAll /* false */) } } else { - // Import new factory defaults but retain all user modified curves. + // Import NEW factory defaults but retain all user modified curves. for (int defCurveCount = 0; defCurveCount < numDefaultCurves; defCurveCount++) { bool isUserCurve = false; // Add if the curve is in the user's set (preserve user's copy) diff --git a/src/effects/Equalization.h b/src/effects/Equalization.h index 896e904b8..0b23b9255 100644 --- a/src/effects/Equalization.h +++ b/src/effects/Equalization.h @@ -143,7 +143,7 @@ private: void LoadCurves(const wxString &fileName = wxEmptyString, bool append = false); void SaveCurves(const wxString &fileName = wxEmptyString); - // Merge new curves only or update all factory presets. + // Merge NEW curves only or update all factory presets. void UpdateDefaultCurves( bool updateAll = false); void Select(int sel); void setCurve(int currentCurve); diff --git a/src/toolbars/ToolDock.cpp b/src/toolbars/ToolDock.cpp index af4cdcf33..3d2c20ae2 100644 --- a/src/toolbars/ToolDock.cpp +++ b/src/toolbars/ToolDock.cpp @@ -139,7 +139,7 @@ void ToolBarConfiguration::Insert(ToolBar *bar, Position position) // Adopt the child only if the insertion point specifies that if (adopt && position.adopt) { - // Make new node with one child + // Make NEW node with one child Tree tree; tree.pBar = bar; tree.children.push_back(Tree{}); @@ -580,7 +580,7 @@ void ToolDock::VisitLayout(LayoutVisitor &visitor, } if (visitor.ShouldVisitSpaces()) { - // Visit the fringe where new leaves of the tree could go + // Visit the fringe where NEW leaves of the tree could go // Find the items with leftover spaces const auto end = std::remove_if(layout, layout + ToolBarCount, @@ -622,7 +622,7 @@ void ToolDock::VisitLayout(LayoutVisitor &visitor, } // Report the final bounding box of all the bars, and a position where - // you can insert a new bar at bottom left. + // you can insert a NEW bar at bottom left. ToolBarConfiguration::Position finalPosition { nullptr, lastRoot }; visitor.FinalRect( wxRect { toolbarGap, toolbarGap, main.width, main.y }, finalPosition diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index dc4a7bb82..72607960b 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -2223,7 +2223,7 @@ void AdornedRulerPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) // Stroke extras direct to the client area, // maybe outside of the damaged area - // As with TrackPanel, do not make a new wxClientDC or else Mac flashes badly! + // As with TrackPanel, do not make a NEW wxClientDC or else Mac flashes badly! dc.DestroyClippingRegion(); DrawOverlays(true, &dc); } From 13e056de43a2191fc09b047886a77665677069ef Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 8 Aug 2016 09:54:53 -0400 Subject: [PATCH 2/3] More uses of safenew --- src/LabelTrack.cpp | 3 ++- src/Menus.cpp | 6 +++--- src/Project.cpp | 4 ++-- src/ShuttleGui.cpp | 4 ++-- src/TimerRecordDialog.cpp | 10 +++++----- src/TrackPanel.h | 4 ++-- src/toolbars/ToolBar.cpp | 2 +- src/toolbars/ToolManager.cpp | 4 +++- src/widgets/ASlider.cpp | 6 ++++-- src/widgets/ErrorDialog.cpp | 8 ++++++-- src/widgets/ExpandingToolBar.cpp | 2 +- 11 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp index e0bae7f6e..2f7cb3246 100644 --- a/src/LabelTrack.cpp +++ b/src/LabelTrack.cpp @@ -2740,7 +2740,8 @@ void LabelTrack::CreateCustomGlyphs() // Create the icon from the tweaked spec. mBoundaryGlyphs[index] = wxBitmap(XmpBmp); // Create the mask - mBoundaryGlyphs[index].SetMask(new wxMask(mBoundaryGlyphs[index], wxColour(192, 192, 192))); + // SetMask takes ownership + mBoundaryGlyphs[index].SetMask(safenew wxMask(mBoundaryGlyphs[index], wxColour(192, 192, 192))); } } diff --git a/src/Menus.cpp b/src/Menus.cpp index cb548d5e1..8b87732e0 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -5370,7 +5370,7 @@ void AudacityProject::OnShowClipping() void AudacityProject::OnHistory() { if (!mHistoryWindow) - mHistoryWindow = new HistoryWindow(this, GetUndoManager()); + mHistoryWindow = safenew HistoryWindow(this, GetUndoManager()); mHistoryWindow->Show(); mHistoryWindow->Raise(); mHistoryWindow->UpdateDisplay(); @@ -5405,7 +5405,7 @@ void AudacityProject::OnPlotSpectrum() where.x = 150; where.y = 150; - mFreqWindow = new FreqWindow(this, -1, _("Frequency Analysis"), where); + mFreqWindow = safenew FreqWindow(this, -1, _("Frequency Analysis"), where); } mFreqWindow->Show(true); @@ -5422,7 +5422,7 @@ void AudacityProject::OnContrast() where.x = 150; where.y = 150; - mContrastDialog = new ContrastDialog(this, -1, _("Contrast Analysis (WCAG 2 compliance)"), where); + mContrastDialog = safenew ContrastDialog(this, -1, _("Contrast Analysis (WCAG 2 compliance)"), where); } mContrastDialog->CentreOnParent(); diff --git a/src/Project.cpp b/src/Project.cpp index 793e0d8c8..3545207f9 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -2033,8 +2033,8 @@ void AudacityProject::OnShow(wxShowEvent & event) // this is a pure wxWidgets event (no GDK event behind it) and that it // therefore isn't processed within the YieldFor(..) of the clipboard // operations (workaround for Debian bug #765341). - wxSizeEvent *sizeEvent = new wxSizeEvent(GetSize()); - GetEventHandler()->QueueEvent(sizeEvent); + // QueueEvent() will take ownership of the event + GetEventHandler()->QueueEvent(safenew wxSizeEvent(GetSize())); // Further processing by default handlers event.Skip(); diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index 0103d2e2b..9b149d7dd 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -2052,7 +2052,7 @@ GuiWaveTrack * ShuttleGui::AddGuiWaveTrack( const wxString & WXUNUSED(Name)) // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), GuiWaveTrack); GuiWaveTrack * pGuiWaveTrack; miProp=1; - mpWind = pGuiWaveTrack = new GuiWaveTrack(mpParent, miId, Name); + mpWind = pGuiWaveTrack = safenew GuiWaveTrack(mpParent, miId, Name); mpWind->SetMinSize(wxSize(100,50)); UpdateSizers(); return pGuiWaveTrack; @@ -2096,7 +2096,7 @@ AttachableScrollBar * ShuttleGui::AddAttachableScrollBar( long style ) // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), AttachableScrollBar); AttachableScrollBar * pAttachableScrollBar; miProp=0; - mpWind = pAttachableScrollBar = new AttachableScrollBar( + mpWind = pAttachableScrollBar = safenew AttachableScrollBar( mpParent, miId, wxDefaultPosition, diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index ff0579959..ceac1476c 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -804,7 +804,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") @@ -815,7 +815,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) #endif 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); @@ -829,7 +829,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") @@ -840,7 +840,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) #endif 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); @@ -861,7 +861,7 @@ void TimerRecordDialog::PopulateOrExchange(ShuttleGui& S) * seconds. */ wxString strFormat1 = _("099 days 024 h 060 m 060 s"); - m_pTimeTextCtrl_Duration = new NumericTextCtrl(NumericConverter::TIME, this, ID_TIMETEXT_DURATION); + m_pTimeTextCtrl_Duration = safenew NumericTextCtrl(NumericConverter::TIME, this, ID_TIMETEXT_DURATION); m_pTimeTextCtrl_Duration->SetName(_("Duration")); m_pTimeTextCtrl_Duration->SetFormatString(strFormat1); m_pTimeTextCtrl_Duration->SetValue(m_TimeSpan_Duration.GetSeconds().ToDouble()); diff --git a/src/TrackPanel.h b/src/TrackPanel.h index bee35c3ac..2bef7e17d 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -556,8 +556,8 @@ protected: // (no GDK event behind it) and that it therefore isn't processed // within the YieldFor(..) of the clipboard operations (workaround // for Debian bug #765341). - wxTimerEvent *event = new wxTimerEvent(*this); - parent->GetEventHandler()->QueueEvent(event); + // QueueEvent() will take ownership of the event + parent->GetEventHandler()->QueueEvent(safenew wxTimerEvent(*this)); } TrackPanel *parent; } mTimer; diff --git a/src/toolbars/ToolBar.cpp b/src/toolbars/ToolBar.cpp index 32940cf26..63615c9a6 100644 --- a/src/toolbars/ToolBar.cpp +++ b/src/toolbars/ToolBar.cpp @@ -758,7 +758,7 @@ AButton * ToolBar::MakeButton(wxWindow *parent, wxImagePtr disable2 (OverlayImage(eUp, eDisabled, xoff, yoff)); AButton * button = - new AButton(parent, id, placement, size, *up2, *hilite2, *down2, + safenew AButton(parent, id, placement, size, *up2, *hilite2, *down2, *disable2, processdownevents); return button; diff --git a/src/toolbars/ToolManager.cpp b/src/toolbars/ToolManager.cpp index 2a7986a7f..d7bc77099 100644 --- a/src/toolbars/ToolManager.cpp +++ b/src/toolbars/ToolManager.cpp @@ -1085,6 +1085,7 @@ void ToolManager::OnMouse( wxMouseEvent & event ) // Done with the floater mDragWindow->Destroy(); + mDragWindow = nullptr; mDragBar->Refresh(false); } else @@ -1335,7 +1336,7 @@ void ToolManager::OnGrabber( GrabberEvent & event ) mDragBar->SetPositioned(); // Construct a NEW floater - mDragWindow = new ToolFrame( mParent, this, mDragBar, mp ); + mDragWindow = safenew ToolFrame( mParent, this, mDragBar, mp ); // Make sure the ferry is visible mDragWindow->Show(); @@ -1377,6 +1378,7 @@ void ToolManager::HandleEscapeKey() // Done with the floater mDragWindow->ClearBar(); mDragWindow->Destroy(); + mDragWindow = nullptr; mDragBar->Refresh(false); } else { diff --git a/src/widgets/ASlider.cpp b/src/widgets/ASlider.cpp index 348fbf77d..beaaaebc9 100644 --- a/src/widgets/ASlider.cpp +++ b/src/widgets/ASlider.cpp @@ -705,7 +705,8 @@ void LWSlider::Draw(wxDC & paintDC) #if !defined(__WXMAC__) // Now create and set the mask - mThumbBitmap->SetMask(new wxMask(*mThumbBitmap, transparentColour)); + // SetMask takes ownership + mThumbBitmap->SetMask(safenew wxMask(*mThumbBitmap, transparentColour)); #endif // @@ -884,7 +885,8 @@ void LWSlider::Draw(wxDC & paintDC) dc.SelectObject(wxNullBitmap); #if !defined(__WXMAC__) - mBitmap->SetMask(new wxMask(*mBitmap, transparentColour)); + // SetMask takes ownership + mBitmap->SetMask(safenew wxMask(*mBitmap, transparentColour)); #endif } diff --git a/src/widgets/ErrorDialog.cpp b/src/widgets/ErrorDialog.cpp index 34a9cb628..0cb633142 100644 --- a/src/widgets/ErrorDialog.cpp +++ b/src/widgets/ErrorDialog.cpp @@ -184,11 +184,13 @@ void ShowModelessErrorDialog(wxWindow *parent, const wxString &helpURL, const bool Close) { - ErrorDialog *dlog = new ErrorDialog(parent, dlogTitle, message, helpURL, Close, false); + ErrorDialog *dlog = safenew ErrorDialog(parent, dlogTitle, message, helpURL, Close, false); dlog->CentreOnParent(); dlog->Show(); // ANSWER-ME: Vigilant Sentry flags this method as not deleting dlog, so a mem leak. // ANSWER-ME: This is unused. Delete it or are there plans for it? + // PRL: answer is that the parent window guarantees destruction of the dialog + // but in practice Destroy() in OnOK does that } void ShowAliasMissingDialog(AudacityProject *parent, @@ -197,7 +199,7 @@ void ShowAliasMissingDialog(AudacityProject *parent, const wxString &helpURL, const bool Close) { - ErrorDialog *dlog = new AliasedFileMissingDialog(parent, dlogTitle, message, helpURL, Close, false); + ErrorDialog *dlog = safenew AliasedFileMissingDialog(parent, dlogTitle, message, helpURL, Close, false); // Don't center because in many cases (effect, export, etc) there will be a progress bar in the center that blocks this. // instead put it just above or on the top of the project. wxPoint point; @@ -214,4 +216,6 @@ void ShowAliasMissingDialog(AudacityProject *parent, // stop playback AND read dialog's instructions. dlog->Show(); // ANSWER-ME: Vigilant Sentry flags this method as not deleting dlog, so a mem leak. + // PRL: answer is that the parent window guarantees destruction of the dialog + // but in practice Destroy() in OnOK does that } diff --git a/src/widgets/ExpandingToolBar.cpp b/src/widgets/ExpandingToolBar.cpp index 1765eca28..031d1d554 100644 --- a/src/widgets/ExpandingToolBar.cpp +++ b/src/widgets/ExpandingToolBar.cpp @@ -152,7 +152,7 @@ ExpandingToolBar::ExpandingToolBar(wxWindow* parent, wxColour magicColor = wxColour(0, 255, 255); ImageArray fourStates = ImageRoll::SplitV(hbar, magicColor); - mToggleButton = new AButton(this, kToggleButtonID, + mToggleButton = safenew AButton(this, kToggleButtonID, wxDefaultPosition, wxDefaultSize, ImageRoll(ImageRoll::HorizontalRoll, fourStates[0], magicColor), From 15004b1adeff4d2fe3fd02ca2c6f8271fd580057 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 8 Aug 2016 09:56:26 -0400 Subject: [PATCH 3/3] More uses of std::make_unique --- src/TrackPanel.cpp | 2 +- src/widgets/AButton.cpp | 2 +- src/widgets/ASlider.cpp | 3 +-- src/widgets/ASlider.h | 2 -- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 14f62dc80..e72a342d0 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -549,7 +549,7 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, #ifdef EXPERIMENTAL_SPECTRAL_EDITING mFreqSelMode = FREQ_SEL_INVALID; - mFrequencySnapper.reset(new SpectrumAnalyst()); + mFrequencySnapper = std::make_unique(); mLastF0 = mLastF1 = SelectedRegion::UndefinedFrequency; #endif diff --git a/src/widgets/AButton.cpp b/src/widgets/AButton.cpp index 2097af780..fd4d92999 100644 --- a/src/widgets/AButton.cpp +++ b/src/widgets/AButton.cpp @@ -292,7 +292,7 @@ void AButton::SetAlternateIdx(unsigned idx) void AButton::FollowModifierKeys() { if(!mListener) - mListener.reset(new Listener(this)); + mListener = std::make_unique(this); } void AButton::SetFocusRect(wxRect & r) diff --git a/src/widgets/ASlider.cpp b/src/widgets/ASlider.cpp index beaaaebc9..d2ddccf87 100644 --- a/src/widgets/ASlider.cpp +++ b/src/widgets/ASlider.cpp @@ -514,7 +514,6 @@ void LWSlider::Init(wxWindow * parent, AdjustSize(size); - mpRuler = NULL; // Do this and Move() before Draw(). Move(pos); } @@ -811,7 +810,7 @@ void LWSlider::Draw(wxDC & paintDC) //{ // if (!mpRuler) // { - // mpRuler = new Ruler(); + // mpRuler = std::make_unique(); // mpRuler->mbTicksOnly = false; // mpRuler->mbTicksAtExtremes = true; diff --git a/src/widgets/ASlider.h b/src/widgets/ASlider.h index b852658b6..7c4ecbd5d 100644 --- a/src/widgets/ASlider.h +++ b/src/widgets/ASlider.h @@ -231,8 +231,6 @@ class LWSlider std::unique_ptr mTipPanel; wxString mTipTemplate; - std::unique_ptr mpRuler; - bool mIsDragging; std::unique_ptr mBitmap, mThumbBitmap;