1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-16 16:47:41 +02:00

Various uses of make_unique

This commit is contained in:
Paul Licameli 2016-08-10 01:34:44 -04:00
parent 11305b956f
commit 14c23803ac
7 changed files with 23 additions and 19 deletions

View File

@ -302,14 +302,15 @@ void BatchProcessDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
{
S.StartStatic(_("Applying..."), 1);
{
wxImageList *imageList = new wxImageList(9, 16);
auto imageList = std::make_unique<wxImageList>(9, 16);
imageList->Add(wxIcon(empty9x16_xpm));
imageList->Add(wxIcon(arrow_xpm));
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
wxLC_SINGLE_SEL);
mList = S.Id(CommandsListID).AddListControlReportMode();
mList->AssignImageList(imageList, wxIMAGE_LIST_SMALL);
// AssignImageList takes ownership
mList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
mList->InsertColumn(0, _("File"), wxLIST_FORMAT_LEFT);
}
S.EndStatic();

View File

@ -64,7 +64,7 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
mSelected = 0;
mAudioIOBusy = false;
wxImageList *imageList = new wxImageList(9, 16);
auto imageList = std::make_unique<wxImageList>(9, 16);
imageList->Add(wxIcon(empty9x16_xpm));
imageList->Add(wxIcon(arrow_xpm));
@ -85,7 +85,8 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
mList->InsertColumn(1, _("Size"), wxLIST_FORMAT_LEFT, 85);
//Assign rather than set the image list, so that it is deleted later.
mList->AssignImageList(imageList, wxIMAGE_LIST_SMALL);
// AssignImageList takes ownership
mList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
S.StartMultiColumn(3, wxCENTRE);
{

View File

@ -116,10 +116,13 @@ WaveTrack::WaveTrack(DirManager *projDirManager, sampleFormat format, double rat
WaveTrack::WaveTrack(const WaveTrack &orig):
Track(orig)
, mpSpectrumSettings(orig.mpSpectrumSettings
? new SpectrogramSettings(*orig.mpSpectrumSettings) : 0
)
? std::make_unique<SpectrogramSettings>(*orig.mpSpectrumSettings)
: nullptr
)
, mpWaveformSettings(orig.mpWaveformSettings
? new WaveformSettings(*orig.mpWaveformSettings) : 0)
? std::make_unique<WaveformSettings>(*orig.mpWaveformSettings)
: nullptr
)
{
mLastScaleType = -1;
mLastdBRange = -1;

View File

@ -412,7 +412,7 @@ private:
};
EffectNoiseReduction::EffectNoiseReduction()
: mSettings(new EffectNoiseReduction::Settings)
: mSettings(std::make_unique<EffectNoiseReduction::Settings>())
{
Init();
}
@ -609,8 +609,8 @@ bool EffectNoiseReduction::Process()
// settings if reducing noise.
if (mSettings->mDoProfile) {
int spectrumSize = 1 + mSettings->WindowSize() / 2;
mStatistics.reset
(new Statistics(spectrumSize, track->GetRate(), mSettings->mWindowTypes));
mStatistics = std::make_unique<Statistics>
(spectrumSize, track->GetRate(), mSettings->mWindowTypes);
}
else if (mStatistics->mWindowSize != mSettings->WindowSize()) {
// possible only with advanced settings

View File

@ -2797,13 +2797,13 @@ void VSTEffect::BuildFancy()
// Turn the power on...some effects need this when the editor is open
PowerOn();
mControl = new VSTControl;
if (!mControl)
auto control = std::make_unique<VSTControl>();
if (!control)
{
return;
}
if (!mControl->Create(mParent, this))
if (!control->Create(mParent, this))
{
return;
}
@ -2811,7 +2811,7 @@ void VSTEffect::BuildFancy()
{
auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
mainSizer->Add(mControl, 0, wxALIGN_CENTER);
mainSizer->Add((mControl = control.release()), 0, wxALIGN_CENTER);
mParent->SetMinSize(wxDefaultSize);
mParent->SetSizer(mainSizer.release());

View File

@ -1778,13 +1778,13 @@ bool AudioUnitEffect::PopulateUI(wxWindow *parent)
}
else
{
mControl = new AUControl;
if (!mControl)
auto pControl = std::make_unique<AUControl>();
if (!pControl)
{
return false;
}
if (!mControl->Create(container, mComponent, mUnit, mUIType == wxT("Full")))
if (!pControl->Create(container, mComponent, mUnit, mUIType == wxT("Full")))
{
return false;
}
@ -1792,7 +1792,7 @@ bool AudioUnitEffect::PopulateUI(wxWindow *parent)
{
auto innerSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
innerSizer->Add(mControl, 1, wxEXPAND);
innerSizer->Add(pControl.release(), 1, wxEXPAND);
container->SetSizer(innerSizer.release());
}

View File

@ -200,7 +200,6 @@ private:
EffectUIHostInterface *mUIHost;
wxWindow *mParent;
wxDialog *mDialog;
AUControl *mControl;
wxString mUIType;
bool mIsGraphical;