1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 16:48:44 +02:00

Remove some naked new amd delete in: TrackPanel::mAx

This commit is contained in:
Paul Licameli 2016-08-02 21:24:53 -04:00
parent 20bee00115
commit 3b6dcfcc32
2 changed files with 13 additions and 7 deletions

View File

@ -441,10 +441,16 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
SetName(_("Track Panel")); SetName(_("Track Panel"));
SetBackgroundStyle(wxBG_STYLE_PAINT); SetBackgroundStyle(wxBG_STYLE_PAINT);
mAx = new TrackPanelAx( this ); {
auto pAx = std::make_unique <TrackPanelAx>( this );
#if wxUSE_ACCESSIBILITY #if wxUSE_ACCESSIBILITY
SetAccessible( mAx ); // wxWidgets owns the accessible object
SetAccessible(mAx = pAx.release());
#else
// wxWidgets doesn not own the object, but we need to retain it
mAx = std::move(pAx);
#endif #endif
}
mMouseCapture = IsUncaptured; mMouseCapture = IsUncaptured;
mSlideUpDownOnly = false; mSlideUpDownOnly = false;
@ -577,10 +583,6 @@ TrackPanel::~TrackPanel()
delete mSnapManager; delete mSnapManager;
DeleteMenus(); DeleteMenus();
#if !wxUSE_ACCESSIBILITY
delete mAx;
#endif
} }
void TrackPanel::BuildMenusIfNeeded(void) void TrackPanel::BuildMenusIfNeeded(void)

View File

@ -786,7 +786,11 @@ protected:
friend class TrackPanelAx; friend class TrackPanelAx;
TrackPanelAx *mAx; #if wxUSE_ACCESSIBILITY
TrackPanelAx *mAx{};
#else
std::unique_ptr<TrackPanelAx> mAx;
#endif
public: public:
TrackPanelAx &GetAx() { return *mAx; } TrackPanelAx &GetAx() { return *mAx; }