mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-10 09:01:13 +02:00
Remove some naked new amd delete in: toolbars
This commit is contained in:
parent
23516a7732
commit
52d12c6913
@ -289,7 +289,7 @@ void ControlToolBar::ArrangeButtons()
|
|||||||
if( mSizer )
|
if( mSizer )
|
||||||
{
|
{
|
||||||
Detach( mSizer );
|
Detach( mSizer );
|
||||||
delete mSizer;
|
std::unique_ptr < wxSizer > {mSizer}; // DELETE it
|
||||||
}
|
}
|
||||||
|
|
||||||
Add((mSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
|
Add((mSizer = safenew wxBoxSizer(wxHORIZONTAL)), 1, wxEXPAND);
|
||||||
@ -359,7 +359,7 @@ void ControlToolBar::ReCreateButtons()
|
|||||||
recordShift = mRecord->WasShiftDown();
|
recordShift = mRecord->WasShiftDown();
|
||||||
Detach( mSizer );
|
Detach( mSizer );
|
||||||
|
|
||||||
delete mSizer;
|
std::unique_ptr < wxSizer > {mSizer}; // DELETE it
|
||||||
mSizer = NULL;
|
mSizer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1185,7 +1185,7 @@ void ControlToolBar::SetupCutPreviewTracks(double WXUNUSED(playStart), double cu
|
|||||||
new2->Clear(cutStart, cutEnd);
|
new2->Clear(cutStart, cutEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
mCutPreviewTracks = new TrackList();
|
mCutPreviewTracks = std::make_unique<TrackList>();
|
||||||
mCutPreviewTracks->Add(std::move(new1));
|
mCutPreviewTracks->Add(std::move(new1));
|
||||||
if (track2)
|
if (track2)
|
||||||
mCutPreviewTracks->Add(std::move(new2));
|
mCutPreviewTracks->Add(std::move(new2));
|
||||||
@ -1196,11 +1196,8 @@ void ControlToolBar::SetupCutPreviewTracks(double WXUNUSED(playStart), double cu
|
|||||||
void ControlToolBar::ClearCutPreviewTracks()
|
void ControlToolBar::ClearCutPreviewTracks()
|
||||||
{
|
{
|
||||||
if (mCutPreviewTracks)
|
if (mCutPreviewTracks)
|
||||||
{
|
mCutPreviewTracks->Clear();
|
||||||
mCutPreviewTracks->Clear(); /* DELETE track contents too */
|
mCutPreviewTracks.reset();
|
||||||
delete mCutPreviewTracks;
|
|
||||||
mCutPreviewTracks = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// works out the width of the field in the status bar needed for the state (eg play, record pause)
|
// works out the width of the field in the status bar needed for the state (eg play, record pause)
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef __AUDACITY_CONTROL_TOOLBAR__
|
#ifndef __AUDACITY_CONTROL_TOOLBAR__
|
||||||
#define __AUDACITY_CONTROL_TOOLBAR__
|
#define __AUDACITY_CONTROL_TOOLBAR__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
#include "ToolBar.h"
|
#include "ToolBar.h"
|
||||||
#include "../Theme.h"
|
#include "../Theme.h"
|
||||||
|
|
||||||
@ -160,7 +161,7 @@ class ControlToolBar final : public ToolBar {
|
|||||||
|
|
||||||
wxBoxSizer *mSizer;
|
wxBoxSizer *mSizer;
|
||||||
|
|
||||||
TrackList* mCutPreviewTracks;
|
std::unique_ptr<TrackList> mCutPreviewTracks;
|
||||||
|
|
||||||
// strings for status bar
|
// strings for status bar
|
||||||
wxString mStatePlay;
|
wxString mStatePlay;
|
||||||
|
@ -67,8 +67,6 @@ DeviceToolBar::DeviceToolBar()
|
|||||||
|
|
||||||
DeviceToolBar::~DeviceToolBar()
|
DeviceToolBar::~DeviceToolBar()
|
||||||
{
|
{
|
||||||
delete mPlayBitmap;
|
|
||||||
delete mRecordBitmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceToolBar::Create(wxWindow *parent)
|
void DeviceToolBar::Create(wxWindow *parent)
|
||||||
@ -102,7 +100,7 @@ void DeviceToolBar::Populate()
|
|||||||
|
|
||||||
// Input device
|
// Input device
|
||||||
if( mRecordBitmap == NULL )
|
if( mRecordBitmap == NULL )
|
||||||
mRecordBitmap = new wxBitmap(theTheme.Bitmap(bmpMic));
|
mRecordBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpMic));
|
||||||
|
|
||||||
Add(safenew wxStaticBitmap(this,
|
Add(safenew wxStaticBitmap(this,
|
||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
@ -122,7 +120,7 @@ void DeviceToolBar::Populate()
|
|||||||
|
|
||||||
// Output device
|
// Output device
|
||||||
if( mPlayBitmap == NULL )
|
if( mPlayBitmap == NULL )
|
||||||
mPlayBitmap = new wxBitmap(theTheme.Bitmap(bmpSpeaker));
|
mPlayBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpSpeaker));
|
||||||
Add(safenew wxStaticBitmap(this,
|
Add(safenew wxStaticBitmap(this,
|
||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
*mPlayBitmap), 0, wxALIGN_CENTER);
|
*mPlayBitmap), 0, wxALIGN_CENTER);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#ifndef __AUDACITY_DEVICE_TOOLBAR__
|
#ifndef __AUDACITY_DEVICE_TOOLBAR__
|
||||||
#define __AUDACITY_DEVICE_TOOLBAR__
|
#define __AUDACITY_DEVICE_TOOLBAR__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "ToolBar.h"
|
#include "ToolBar.h"
|
||||||
|
|
||||||
@ -67,8 +68,7 @@ class DeviceToolBar final : public ToolBar {
|
|||||||
|
|
||||||
void ShowComboDialog(wxChoice *combo, const wxString &title);
|
void ShowComboDialog(wxChoice *combo, const wxString &title);
|
||||||
|
|
||||||
wxBitmap *mPlayBitmap;
|
std::unique_ptr<wxBitmap> mPlayBitmap, mRecordBitmap;
|
||||||
wxBitmap *mRecordBitmap;
|
|
||||||
|
|
||||||
wxChoice *mInput;
|
wxChoice *mInput;
|
||||||
wxChoice *mOutput;
|
wxChoice *mOutput;
|
||||||
|
@ -66,8 +66,6 @@ MixerToolBar::MixerToolBar()
|
|||||||
|
|
||||||
MixerToolBar::~MixerToolBar()
|
MixerToolBar::~MixerToolBar()
|
||||||
{
|
{
|
||||||
delete mPlayBitmap;
|
|
||||||
delete mRecordBitmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixerToolBar::Create(wxWindow *parent)
|
void MixerToolBar::Create(wxWindow *parent)
|
||||||
@ -78,7 +76,7 @@ void MixerToolBar::Create(wxWindow *parent)
|
|||||||
void MixerToolBar::Populate()
|
void MixerToolBar::Populate()
|
||||||
{
|
{
|
||||||
if( mRecordBitmap == NULL )
|
if( mRecordBitmap == NULL )
|
||||||
mRecordBitmap = new wxBitmap(theTheme.Bitmap(bmpMic));
|
mRecordBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpMic));
|
||||||
|
|
||||||
Add(safenew wxStaticBitmap(this,
|
Add(safenew wxStaticBitmap(this,
|
||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
@ -91,7 +89,7 @@ void MixerToolBar::Populate()
|
|||||||
Add(mInputSlider, 0, wxALIGN_CENTER);
|
Add(mInputSlider, 0, wxALIGN_CENTER);
|
||||||
|
|
||||||
if( mPlayBitmap == NULL )
|
if( mPlayBitmap == NULL )
|
||||||
mPlayBitmap = new wxBitmap(theTheme.Bitmap(bmpSpeaker));
|
mPlayBitmap = std::make_unique<wxBitmap>(theTheme.Bitmap(bmpSpeaker));
|
||||||
|
|
||||||
Add(safenew wxStaticBitmap(this,
|
Add(safenew wxStaticBitmap(this,
|
||||||
wxID_ANY,
|
wxID_ANY,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#ifndef __AUDACITY_MIXER_TOOLBAR__
|
#ifndef __AUDACITY_MIXER_TOOLBAR__
|
||||||
#define __AUDACITY_MIXER_TOOLBAR__
|
#define __AUDACITY_MIXER_TOOLBAR__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
#include "ToolBar.h"
|
#include "ToolBar.h"
|
||||||
|
|
||||||
class wxImage;
|
class wxImage;
|
||||||
@ -60,8 +61,7 @@ class MixerToolBar final : public ToolBar {
|
|||||||
void InitializeMixerToolBar();
|
void InitializeMixerToolBar();
|
||||||
void SetToolTips();
|
void SetToolTips();
|
||||||
|
|
||||||
wxBitmap *mPlayBitmap;
|
std::unique_ptr<wxBitmap> mPlayBitmap, mRecordBitmap;
|
||||||
wxBitmap *mRecordBitmap;
|
|
||||||
|
|
||||||
ASlider *mInputSlider;
|
ASlider *mInputSlider;
|
||||||
ASlider *mOutputSlider;
|
ASlider *mOutputSlider;
|
||||||
|
@ -349,7 +349,7 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
|
|||||||
pt[ 2 ].y = 0;
|
pt[ 2 ].y = 0;
|
||||||
|
|
||||||
// Create the shaped region
|
// Create the shaped region
|
||||||
mDown = new wxRegion( 3, &pt[0] );
|
mDown = std::make_unique<wxRegion>( 3, &pt[0] );
|
||||||
|
|
||||||
// Create the down arrow
|
// Create the down arrow
|
||||||
pt[ 0 ].x = 9;
|
pt[ 0 ].x = 9;
|
||||||
@ -360,7 +360,7 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
|
|||||||
pt[ 2 ].y = 18;
|
pt[ 2 ].y = 18;
|
||||||
|
|
||||||
// Create the shaped region
|
// Create the shaped region
|
||||||
mLeft = new wxRegion( 3, &pt[0] );
|
mLeft = std::make_unique<wxRegion>( 3, &pt[0] );
|
||||||
|
|
||||||
// Create the indicator frame
|
// Create the indicator frame
|
||||||
mIndicator = new wxFrame( NULL,
|
mIndicator = new wxFrame( NULL,
|
||||||
@ -465,10 +465,6 @@ ToolManager::~ToolManager()
|
|||||||
|
|
||||||
// Must destroy the window since it doesn't have a parent
|
// Must destroy the window since it doesn't have a parent
|
||||||
mIndicator->Destroy();
|
mIndicator->Destroy();
|
||||||
|
|
||||||
// Delete the indicator regions
|
|
||||||
delete mLeft;
|
|
||||||
delete mDown;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This table describes the default configuration of the toolbars as
|
// This table describes the default configuration of the toolbars as
|
||||||
@ -1159,14 +1155,14 @@ void ToolManager::OnMouse( wxMouseEvent & event )
|
|||||||
p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
|
p.x = dr.GetLeft() + ( dr.GetWidth() / 2 )
|
||||||
- (box.GetWidth() / 2);
|
- (box.GetWidth() / 2);
|
||||||
p.y = dr.GetBottom() - box.GetHeight();
|
p.y = dr.GetBottom() - box.GetHeight();
|
||||||
mCurrent = mDown;
|
mCurrent = mDown.get();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.x = dr.GetLeft() + r.GetLeft();
|
p.x = dr.GetLeft() + r.GetLeft();
|
||||||
p.y = dr.GetTop() + r.GetTop() +
|
p.y = dr.GetTop() + r.GetTop() +
|
||||||
( ( r.GetHeight() - mLeft->GetBox().GetHeight() ) / 2 );
|
( ( r.GetHeight() - mLeft->GetBox().GetHeight() ) / 2 );
|
||||||
mCurrent = mLeft;
|
mCurrent = mLeft.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change the shape while hidden and then show it if okay
|
// Change the shape while hidden and then show it if okay
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#ifndef __AUDACITY_TOOLMANAGER__
|
#ifndef __AUDACITY_TOOLMANAGER__
|
||||||
#define __AUDACITY_TOOLMANAGER__
|
#define __AUDACITY_TOOLMANAGER__
|
||||||
|
|
||||||
|
#include "../MemoryX.h"
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
#include <wx/timer.h>
|
#include <wx/timer.h>
|
||||||
@ -97,8 +98,7 @@ class ToolManager final : public wxEvtHandler
|
|||||||
wxRect mBarPos;
|
wxRect mBarPos;
|
||||||
|
|
||||||
wxFrame *mIndicator;
|
wxFrame *mIndicator;
|
||||||
wxRegion *mLeft;
|
std::unique_ptr<wxRegion> mLeft, mDown;
|
||||||
wxRegion *mDown;
|
|
||||||
wxRegion *mCurrent;
|
wxRegion *mCurrent;
|
||||||
|
|
||||||
wxTimer mTimer;
|
wxTimer mTimer;
|
||||||
|
@ -93,15 +93,12 @@ TranscriptionToolBar::TranscriptionToolBar()
|
|||||||
{
|
{
|
||||||
mPlaySpeed = 1.0 * 100.0;
|
mPlaySpeed = 1.0 * 100.0;
|
||||||
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
||||||
mVk = new VoiceKey();
|
mVk = std::make_unique<VoiceKey>();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TranscriptionToolBar::~TranscriptionToolBar()
|
TranscriptionToolBar::~TranscriptionToolBar()
|
||||||
{
|
{
|
||||||
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
|
||||||
delete mVk;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranscriptionToolBar::Create(wxWindow * parent)
|
void TranscriptionToolBar::Create(wxWindow * parent)
|
||||||
|
@ -98,13 +98,13 @@ class TranscriptionToolBar final : public ToolBar {
|
|||||||
void OnAutomateSelection(wxCommandEvent & event);
|
void OnAutomateSelection(wxCommandEvent & event);
|
||||||
void OnSensitivitySlider(wxCommandEvent & event);
|
void OnSensitivitySlider(wxCommandEvent & event);
|
||||||
|
|
||||||
void Populate() override;
|
//void Populate() override;
|
||||||
void Repaint(wxDC * WXUNUSED(dc)) override {}
|
//void Repaint(wxDC * WXUNUSED(dc)) override {}
|
||||||
void EnableDisableButtons() override;
|
//void EnableDisableButtons() override;
|
||||||
void UpdatePrefs() override;
|
//void UpdatePrefs() override;
|
||||||
|
|
||||||
void OnFocus(wxFocusEvent &event);
|
//void OnFocus(wxFocusEvent &event);
|
||||||
void OnCaptureKey(wxCommandEvent &event);
|
//void OnCaptureKey(wxCommandEvent &event);
|
||||||
|
|
||||||
double GetSensitivity();
|
double GetSensitivity();
|
||||||
void SetKeyType(wxCommandEvent & event);
|
void SetKeyType(wxCommandEvent & event);
|
||||||
@ -144,7 +144,7 @@ class TranscriptionToolBar final : public ToolBar {
|
|||||||
|
|
||||||
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
||||||
double mSensitivity;
|
double mSensitivity;
|
||||||
VoiceKey *mVk;
|
std::unique_ptr<VoiceKey> mVk;
|
||||||
wxChoice *mKeyTypeChoice;
|
wxChoice *mKeyTypeChoice;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user