Remove various scalar naked news and deletes
This commit is contained in:
commit
062e50eca6
|
@ -1203,7 +1203,8 @@ bool AudacityApp::OnInit()
|
|||
|
||||
::wxInitAllImageHandlers();
|
||||
|
||||
wxFileSystem::AddHandler(new wxZipFSHandler);
|
||||
// AddHandler takes ownership
|
||||
wxFileSystem::AddHandler(safenew wxZipFSHandler);
|
||||
|
||||
//
|
||||
// Paths: set search path and temp dir path
|
||||
|
@ -1433,17 +1434,18 @@ bool AudacityApp::OnInit()
|
|||
// On the Mac, users don't expect a program to quit when you close the last window.
|
||||
// Create a menubar that will show when all project windows are closed.
|
||||
|
||||
wxMenu *fileMenu = new wxMenu();
|
||||
wxMenu *recentMenu = new wxMenu();
|
||||
auto fileMenu = std::make_unique<wxMenu>();
|
||||
auto urecentMenu = std::make_unique<wxMenu>();
|
||||
auto recentMenu = urecentMenu.get();
|
||||
fileMenu->Append(wxID_NEW, wxString(_("&New")) + wxT("\tCtrl+N"));
|
||||
fileMenu->Append(wxID_OPEN, wxString(_("&Open...")) + wxT("\tCtrl+O"));
|
||||
fileMenu->AppendSubMenu(recentMenu, _("Open &Recent..."));
|
||||
fileMenu->AppendSubMenu(urecentMenu.release(), _("Open &Recent..."));
|
||||
fileMenu->Append(wxID_ABOUT, _("&About Audacity..."));
|
||||
fileMenu->Append(wxID_PREFERENCES, wxString(_("&Preferences...")) + wxT("\tCtrl+,"));
|
||||
|
||||
{
|
||||
auto menuBar = std::make_unique<wxMenuBar>();
|
||||
menuBar->Append(fileMenu, _("&File"));
|
||||
menuBar->Append(fileMenu.release(), _("&File"));
|
||||
|
||||
// PRL: Are we sure wxWindows will not leak this menuBar?
|
||||
// The online documentation is not explicit.
|
||||
|
@ -1766,33 +1768,34 @@ bool AudacityApp::CreateSingleInstanceChecker(const wxString &dir)
|
|||
wxUNIXaddress addr;
|
||||
addr.Filename(sockFile);
|
||||
|
||||
// Setup the socket
|
||||
wxSocketClient *sock = new wxSocketClient();
|
||||
sock->SetFlags(wxSOCKET_WAITALL);
|
||||
|
||||
// We try up to 50 times since there's a small window
|
||||
// where the server may not have been fully initialized.
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
// Connect to the existing Audacity
|
||||
sock->Connect(addr, true);
|
||||
if (sock->IsConnected())
|
||||
// Setup the socket
|
||||
// A wxSocketClient must not be deleted by us, but rather, let the
|
||||
// framework do appropriate delayed deletion after Destroy()
|
||||
Destroy_ptr<wxSocketClient> sock { safenew wxSocketClient() };
|
||||
sock->SetFlags(wxSOCKET_WAITALL);
|
||||
|
||||
// We try up to 50 times since there's a small window
|
||||
// where the server may not have been fully initialized.
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
|
||||
// Connect to the existing Audacity
|
||||
sock->Connect(addr, true);
|
||||
if (sock->IsConnected())
|
||||
{
|
||||
// Send the filename
|
||||
wxString param = parser->GetParam(i);
|
||||
sock->WriteMsg((const wxChar *) param.c_str(), (param.Len() + 1) * sizeof(wxChar));
|
||||
for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
|
||||
{
|
||||
// Send the filename
|
||||
wxString param = parser->GetParam(i);
|
||||
sock->WriteMsg((const wxChar *) param.c_str(), (param.Len() + 1) * sizeof(wxChar));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
sock->Destroy();
|
||||
return false;
|
||||
wxMilliSleep(100);
|
||||
}
|
||||
|
||||
wxMilliSleep(100);
|
||||
}
|
||||
|
||||
sock->Destroy();
|
||||
#endif
|
||||
// There is another copy of Audacity running. Force quit.
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
{
|
||||
|
|
|
@ -154,7 +154,7 @@ void LabelTrack::SetOffset(double dOffset)
|
|||
|
||||
bool LabelTrack::Clear(double b, double e)
|
||||
{
|
||||
// May delete labels, so use subscripts to iterate
|
||||
// May DELETE labels, so use subscripts to iterate
|
||||
for (size_t i = 0; i < mLabels.size(); ++i) {
|
||||
auto &labelStruct = mLabels[i];
|
||||
LabelStruct::TimeRelations relation =
|
||||
|
@ -182,7 +182,7 @@ bool LabelTrack::Clear(double b, double e)
|
|||
//used when we want to use clear only on the labels
|
||||
bool LabelTrack::SplitDelete(double b, double e)
|
||||
{
|
||||
// May delete labels, so use subscripts to iterate
|
||||
// May DELETE labels, so use subscripts to iterate
|
||||
for (size_t i = 0, len = mLabels.size(); i < len; ++i) {
|
||||
auto &labelStruct = mLabels[i];
|
||||
LabelStruct::TimeRelations relation =
|
||||
|
@ -2292,23 +2292,18 @@ bool LabelTrack::Load(wxTextFile * in, DirManager * dirManager)
|
|||
if (!(in->GetNextLine().ToULong(&len)))
|
||||
return false;
|
||||
|
||||
for (auto pLabel : mLabels)
|
||||
delete pLabel;
|
||||
|
||||
mLabels.clear();
|
||||
mLabels.reserve(len);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
LabelStruct *l = new LabelStruct();
|
||||
double t0;
|
||||
if (!Internat::CompatibleToDouble(in->GetNextLine(), &t0))
|
||||
return false;
|
||||
l->selectedRegion.setT0(t0, false);
|
||||
// Legacy file format does not include label end-times.
|
||||
l->selectedRegion.collapseToT0();
|
||||
// PRL: nothing NEW to do, legacy file support
|
||||
l->title = in->GetNextLine();
|
||||
mLabels.Add(l);
|
||||
mLabels.push_back(LabelStruct {
|
||||
SelectedRegion{ t0, t0 }, in->GetNextLine()
|
||||
});
|
||||
}
|
||||
|
||||
if (in->GetNextLine() != wxT("MLabelsEnd"))
|
||||
|
|
|
@ -568,7 +568,7 @@ public:
|
|||
{
|
||||
// Lose any old value
|
||||
reset();
|
||||
// Create new value
|
||||
// Create NEW value
|
||||
pp = safenew(address()) X(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
@ -688,6 +688,22 @@ make_movable_with_deleter(const Deleter &d, Args&&... args)
|
|||
return movable_ptr_with_deleter<T, Deleter>(safenew T(std::forward<Args>(args)...), d);
|
||||
}
|
||||
|
||||
/*
|
||||
* A deleter class to supply the second template parameter of unique_ptr for
|
||||
* classes like wxWindow that should be sent a message called Destroy rather
|
||||
* than be deleted directly
|
||||
*/
|
||||
template <typename T>
|
||||
struct Destroyer {
|
||||
void operator () (T *p) const { if (p) p->Destroy(); }
|
||||
};
|
||||
|
||||
/*
|
||||
* a convenience for using Destroyer
|
||||
*/
|
||||
template <typename T>
|
||||
using Destroy_ptr = std::unique_ptr<T, Destroyer<T>>;
|
||||
|
||||
/*
|
||||
* "finally" as in The C++ Programming Language, 4th ed., p. 358
|
||||
* Useful for defining ad-hoc RAII actions.
|
||||
|
|
|
@ -33,8 +33,11 @@
|
|||
#include "Experimental.h"
|
||||
|
||||
// Globals, so that we remember settings from session to session
|
||||
static wxPrintData *gPrintData = NULL;
|
||||
static wxPageSetupData *gPageSetupData = NULL;
|
||||
wxPrintData &gPrintData()
|
||||
{
|
||||
static wxPrintData theData;
|
||||
return theData;
|
||||
}
|
||||
|
||||
class AudacityPrintout final : public wxPrintout
|
||||
{
|
||||
|
@ -139,28 +142,17 @@ void AudacityPrintout::GetPageInfo(int *minPage, int *maxPage,
|
|||
|
||||
void HandlePageSetup(wxWindow *parent)
|
||||
{
|
||||
if (gPageSetupData == NULL)
|
||||
gPageSetupData = new wxPageSetupDialogData();
|
||||
if (gPrintData == NULL)
|
||||
gPrintData = new wxPrintData();
|
||||
wxPageSetupData pageSetupData;
|
||||
|
||||
(*gPageSetupData) = *gPrintData;
|
||||
|
||||
wxPageSetupDialog pageSetupDialog(parent, gPageSetupData);
|
||||
wxPageSetupDialog pageSetupDialog(parent, &pageSetupData);
|
||||
pageSetupDialog.ShowModal();
|
||||
|
||||
(*gPrintData) = pageSetupDialog.GetPageSetupData().GetPrintData();
|
||||
(*gPageSetupData) = pageSetupDialog.GetPageSetupData();
|
||||
gPrintData() = pageSetupDialog.GetPageSetupData().GetPrintData();
|
||||
}
|
||||
|
||||
void HandlePrint(wxWindow *parent, const wxString &name, TrackList *tracks)
|
||||
{
|
||||
if (gPageSetupData == NULL)
|
||||
gPageSetupData = new wxPageSetupDialogData();
|
||||
if (gPrintData == NULL)
|
||||
gPrintData = new wxPrintData();
|
||||
|
||||
wxPrintDialogData printDialogData(*gPrintData);
|
||||
wxPrintDialogData printDialogData(gPrintData());
|
||||
|
||||
wxPrinter printer(&printDialogData);
|
||||
AudacityPrintout printout(name, tracks);
|
||||
|
@ -174,6 +166,6 @@ void HandlePrint(wxWindow *parent, const wxString &name, TrackList *tracks)
|
|||
}
|
||||
}
|
||||
else {
|
||||
*gPrintData = printer.GetPrintDialogData().GetPrintData();
|
||||
gPrintData() = printer.GetPrintDialogData().GetPrintData();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,7 +340,8 @@ public:
|
|||
{
|
||||
mProject = proj;
|
||||
|
||||
SetDataObject(new FileObject());
|
||||
// SetDataObject takes ownership
|
||||
SetDataObject(safenew FileObject());
|
||||
}
|
||||
|
||||
~DropTarget()
|
||||
|
@ -1110,9 +1111,11 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
|||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
// We can import now, so become a drag target
|
||||
// SetDropTarget(new AudacityDropTarget(this));
|
||||
// mTrackPanel->SetDropTarget(new AudacityDropTarget(this));
|
||||
mTrackPanel->SetDropTarget(new DropTarget(this));
|
||||
// SetDropTarget(safenew AudacityDropTarget(this));
|
||||
// mTrackPanel->SetDropTarget(safenew AudacityDropTarget(this));
|
||||
|
||||
// SetDropTarget takes ownership
|
||||
mTrackPanel->SetDropTarget(safenew DropTarget(this));
|
||||
#endif
|
||||
|
||||
wxTheApp->Connect(EVT_AUDIOIO_CAPTURE,
|
||||
|
|
|
@ -111,14 +111,15 @@ class ScreenFrame final : public wxFrame
|
|||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
static ScreenFrame *mFrame = NULL;
|
||||
using ScreenFramePtr = Destroy_ptr<ScreenFrame>;
|
||||
ScreenFramePtr mFrame;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OpenScreenshotTools()
|
||||
{
|
||||
if (!mFrame) {
|
||||
mFrame = new ScreenFrame(NULL, -1);
|
||||
mFrame = ScreenFramePtr{ safenew ScreenFrame(NULL, -1) };
|
||||
}
|
||||
mFrame->Show();
|
||||
mFrame->Raise();
|
||||
|
@ -126,10 +127,7 @@ void OpenScreenshotTools()
|
|||
|
||||
void CloseScreenshotTools()
|
||||
{
|
||||
if (mFrame) {
|
||||
mFrame->Destroy();
|
||||
mFrame = NULL;
|
||||
}
|
||||
mFrame.reset();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -485,7 +483,8 @@ bool ScreenFrame::ProcessEvent(wxEvent & e)
|
|||
|
||||
void ScreenFrame::OnCloseWindow(wxCloseEvent & WXUNUSED(event))
|
||||
{
|
||||
mFrame = NULL;
|
||||
if (this == mFrame.get())
|
||||
mFrame.release();
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,8 @@ void SplashDialog::Show2( wxWindow * pParent )
|
|||
{
|
||||
if( pSelf == NULL )
|
||||
{
|
||||
pSelf = new SplashDialog( pParent );
|
||||
// pParent owns it
|
||||
pSelf = safenew SplashDialog( pParent );
|
||||
}
|
||||
pSelf->mpHtml->SetPage(HelpText( wxT("welcome") ));
|
||||
pSelf->Show( true );
|
||||
|
|
|
@ -163,8 +163,10 @@ public:
|
|||
// //this array is sorted by start/end points and has no overlaps. If we've passed all possible intersections, insert. The array will remain sorted.
|
||||
// if(region.end < invalStart)
|
||||
// {
|
||||
// InvalidRegion* newRegion = new InvalidRegion(invalStart,invalEnd);
|
||||
// mRegions.insert(mRegions.begin()+i,newRegion);
|
||||
// mRegions.insert(
|
||||
// mRegions.begin() + i,
|
||||
// InvalidRegion{ invalStart, invalEnd }
|
||||
// );
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -202,7 +205,7 @@ void WaveTrack::SetOffset(double o)
|
|||
WaveTrack::WaveTrackDisplay WaveTrack::FindDefaultViewMode()
|
||||
{
|
||||
// PRL: Bugs 1043, 1044
|
||||
// 2.1.1 writes a NEW key for this preference, which got new values,
|
||||
// 2.1.1 writes a NEW key for this preference, which got NEW values,
|
||||
// to avoid confusing version 2.1.0 if it reads the preference file afterwards.
|
||||
// Prefer the NEW preference key if it is present
|
||||
|
||||
|
|
|
@ -779,15 +779,15 @@ void Effect::Preview()
|
|||
|
||||
wxDialog *Effect::CreateUI(wxWindow *parent, EffectUIClientInterface *client)
|
||||
{
|
||||
EffectUIHost *dlg = new EffectUIHost(parent, this, client);
|
||||
Destroy_ptr<EffectUIHost> dlg
|
||||
{ safenew EffectUIHost{ parent, this, client} };
|
||||
|
||||
if (dlg->Initialize())
|
||||
{
|
||||
return dlg;
|
||||
// release() is safe because parent will own it
|
||||
return dlg.release();
|
||||
}
|
||||
|
||||
delete dlg;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2929,7 +2929,7 @@ int EffectUIHost::ShowModal()
|
|||
sz->Replace(mCloseBtn, apply);
|
||||
sz->Replace(mApplyBtn, mCloseBtn);
|
||||
sz->Layout();
|
||||
delete mApplyBtn;
|
||||
mApplyBtn->Destroy();
|
||||
mApplyBtn = apply;
|
||||
mApplyBtn->SetDefault();
|
||||
mApplyBtn->SetLabel(wxGetStockLabel(wxID_OK, 0));
|
||||
|
@ -3290,7 +3290,6 @@ void EffectUIHost::OnDebug(wxCommandEvent & evt)
|
|||
void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
wxMenu menu;
|
||||
wxMenu *sub;
|
||||
|
||||
LoadUserPresets();
|
||||
|
||||
|
@ -3300,12 +3299,12 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
|
|||
}
|
||||
else
|
||||
{
|
||||
sub = new wxMenu();
|
||||
auto sub = std::make_unique<wxMenu>();
|
||||
for (size_t i = 0, cnt = mUserPresets.GetCount(); i < cnt; i++)
|
||||
{
|
||||
sub->Append(kUserPresetsID + i, mUserPresets[i]);
|
||||
}
|
||||
menu.Append(0, _("User Presets"), sub);
|
||||
menu.Append(0, _("User Presets"), sub.release());
|
||||
}
|
||||
|
||||
menu.Append(kSaveAsID, _("Save Preset..."));
|
||||
|
@ -3316,35 +3315,37 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
|
|||
}
|
||||
else
|
||||
{
|
||||
sub = new wxMenu();
|
||||
auto sub = std::make_unique<wxMenu>();
|
||||
for (size_t i = 0, cnt = mUserPresets.GetCount(); i < cnt; i++)
|
||||
{
|
||||
sub->Append(kDeletePresetID + i, mUserPresets[i]);
|
||||
}
|
||||
menu.Append(0, _("Delete Preset"), sub);
|
||||
menu.Append(0, _("Delete Preset"), sub.release());
|
||||
}
|
||||
|
||||
menu.AppendSeparator();
|
||||
|
||||
wxArrayString factory = mEffect->GetFactoryPresets();
|
||||
|
||||
sub = new wxMenu();
|
||||
sub->Append(kDefaultsID, _("Defaults"));
|
||||
if (factory.GetCount() > 0)
|
||||
{
|
||||
sub->AppendSeparator();
|
||||
for (size_t i = 0, cnt = factory.GetCount(); i < cnt; i++)
|
||||
auto sub = std::make_unique<wxMenu>();
|
||||
sub->Append(kDefaultsID, _("Defaults"));
|
||||
if (factory.GetCount() > 0)
|
||||
{
|
||||
wxString label = factory[i];
|
||||
if (label.IsEmpty())
|
||||
sub->AppendSeparator();
|
||||
for (size_t i = 0, cnt = factory.GetCount(); i < cnt; i++)
|
||||
{
|
||||
label = _("None");
|
||||
}
|
||||
wxString label = factory[i];
|
||||
if (label.IsEmpty())
|
||||
{
|
||||
label = _("None");
|
||||
}
|
||||
|
||||
sub->Append(kFactoryPresetsID + i, label);
|
||||
sub->Append(kFactoryPresetsID + i, label);
|
||||
}
|
||||
}
|
||||
menu.Append(0, _("Factory Presets"), sub.release());
|
||||
}
|
||||
menu.Append(0, _("Factory Presets"), sub);
|
||||
|
||||
menu.AppendSeparator();
|
||||
menu.Append(kImportID, _("Import..."))->Enable(mClient->CanExportPresets());
|
||||
|
@ -3353,15 +3354,17 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
|
|||
menu.Append(kOptionsID, _("Options..."))->Enable(mClient->HasOptions());
|
||||
menu.AppendSeparator();
|
||||
|
||||
sub = new wxMenu();
|
||||
{
|
||||
auto sub = std::make_unique<wxMenu>();
|
||||
|
||||
sub->Append(kDummyID, wxString::Format(_("Type: %s"), mEffect->GetFamily().c_str()));
|
||||
sub->Append(kDummyID, wxString::Format(_("Name: %s"), mEffect->GetName().c_str()));
|
||||
sub->Append(kDummyID, wxString::Format(_("Version: %s"), mEffect->GetVersion().c_str()));
|
||||
sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), mEffect->GetVendor().c_str()));
|
||||
sub->Append(kDummyID, wxString::Format(_("Description: %s"), mEffect->GetDescription().c_str()));
|
||||
sub->Append(kDummyID, wxString::Format(_("Type: %s"), mEffect->GetFamily().c_str()));
|
||||
sub->Append(kDummyID, wxString::Format(_("Name: %s"), mEffect->GetName().c_str()));
|
||||
sub->Append(kDummyID, wxString::Format(_("Version: %s"), mEffect->GetVersion().c_str()));
|
||||
sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), mEffect->GetVendor().c_str()));
|
||||
sub->Append(kDummyID, wxString::Format(_("Description: %s"), mEffect->GetDescription().c_str()));
|
||||
|
||||
menu.Append(0, _("About"), sub);
|
||||
menu.Append(0, _("About"), sub.release());
|
||||
}
|
||||
|
||||
wxWindow *btn = FindWindow(kMenuID);
|
||||
wxRect r = btn->GetRect();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -27,7 +27,7 @@ effect that uses SoundTouch to do its processing (ChangeTempo
|
|||
|
||||
bool EffectSoundTouch::ProcessLabelTrack(Track *track)
|
||||
{
|
||||
// SetTimeWarper(new RegionTimeWarper(mCurT0, mCurT1,
|
||||
// SetTimeWarper(std::make_unique<RegionTimeWarper>(mCurT0, mCurT1,
|
||||
// std::make_unique<LinearTimeWarper>(mCurT0, mCurT0,
|
||||
// mCurT1, mCurT0 + (mCurT1-mCurT0)*mFactor)));
|
||||
LabelTrack *lt = (LabelTrack*)track;
|
||||
|
|
|
@ -660,9 +660,6 @@ bool EffectTruncSilence::Analyze(RegionList& silenceList,
|
|||
}
|
||||
|
||||
// Record the silent region
|
||||
Region *r = new Region;
|
||||
r->start = wt->LongSamplesToTime(*index + i - *silentFrame);
|
||||
r->end = wt->LongSamplesToTime(*index + i);
|
||||
trackSilences.push_back(Region(
|
||||
wt->LongSamplesToTime(*index + i - *silentFrame),
|
||||
wt->LongSamplesToTime(*index + i)
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,6 @@ private:
|
|||
EffectUIHostInterface *mUIHost;
|
||||
wxWindow *mParent;
|
||||
wxDialog *mDialog;
|
||||
AUControl *mControl;
|
||||
wxString mUIType;
|
||||
bool mIsGraphical;
|
||||
|
||||
|
|
|
@ -218,7 +218,9 @@ void ODManager::Init()
|
|||
mMaxThreads = 5;
|
||||
|
||||
// wxLogDebug(wxT("Initializing ODManager...Creating manager thread"));
|
||||
ODManagerHelperThread* startThread = new ODManagerHelperThread;
|
||||
// This is a detached thread, so it deletes itself when it finishes
|
||||
// ... except on Mac where we we don't use wxThread for reasons unexplained
|
||||
ODManagerHelperThread* startThread = safenew ODManagerHelperThread;
|
||||
|
||||
// startThread->SetPriority(0);//default of 50.
|
||||
startThread->Create();
|
||||
|
@ -239,7 +241,6 @@ void ODManager::DecrementCurrentThreads()
|
|||
///Main loop for managing threads and tasks.
|
||||
void ODManager::Start()
|
||||
{
|
||||
ODTaskThread* thread;
|
||||
bool tasksInArray;
|
||||
bool paused;
|
||||
int numQueues=0;
|
||||
|
@ -278,7 +279,9 @@ void ODManager::Start()
|
|||
|
||||
mTasksMutex.Lock();
|
||||
//detach a NEW thread.
|
||||
thread = new ODTaskThread(mTasks[0]);//task);
|
||||
// This is a detached thread, so it deletes itself when it finishes
|
||||
// ... except on Mac where we we don't use wxThread for reasons unexplained
|
||||
auto thread = safenew ODTaskThread(mTasks[0]);//task);
|
||||
//thread->SetPriority(10);//default is 50.
|
||||
thread->Create();
|
||||
thread->Run();
|
||||
|
|
|
@ -222,7 +222,7 @@ class ODManagerHelperThread {
|
|||
class ODManagerHelperThread final : public wxThread
|
||||
{
|
||||
public:
|
||||
///Constructs a ODTaskThread
|
||||
///Constructs an ODManagerHelperThread
|
||||
///@param task the task to be launched as an
|
||||
ODManagerHelperThread(): wxThread(){}
|
||||
|
||||
|
|
|
@ -62,12 +62,6 @@ ExtImportPrefs::ExtImportPrefs(wxWindow * parent)
|
|||
PluginList(NULL), mCreateTable (false), mDragFocus (NULL),
|
||||
mFakeKeyEvent (false), mStopRecursiveSelection (false), last_selected (-1)
|
||||
{
|
||||
dragtext1 = new wxTextDataObject(wxT(""));
|
||||
dragtext2 = new wxTextDataObject(wxT(""));
|
||||
dragtarget1 = new ExtImportPrefsDropTarget(dragtext1);
|
||||
dragtarget2 = new ExtImportPrefsDropTarget(dragtext2);
|
||||
dragtarget1->SetPrefs (this);
|
||||
dragtarget2->SetPrefs (this);
|
||||
Populate();
|
||||
}
|
||||
|
||||
|
@ -121,7 +115,14 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||
RuleTable->SetSelectionMode (wxGrid::wxGridSelectRows);
|
||||
RuleTable->AutoSizeColumns ();
|
||||
|
||||
RuleTable->SetDropTarget (dragtarget1);
|
||||
ExtImportPrefsDropTarget *dragtarget1 {};
|
||||
RuleTable->SetDropTarget (
|
||||
dragtarget1 = safenew ExtImportPrefsDropTarget(
|
||||
dragtext1 = safenew wxTextDataObject(wxT(""))
|
||||
)
|
||||
);
|
||||
dragtarget1->SetPrefs (this);
|
||||
|
||||
RuleTable->EnableDragCell (true);
|
||||
fillRuleTable = true;
|
||||
}
|
||||
|
@ -134,7 +135,15 @@ void ExtImportPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||
PluginList->SetSingleStyle (wxLC_REPORT, true);
|
||||
PluginList->SetSingleStyle (wxLC_SINGLE_SEL, true);
|
||||
PluginList->InsertColumn (0, _("Importer order"));
|
||||
PluginList->SetDropTarget (dragtarget2);
|
||||
|
||||
ExtImportPrefsDropTarget *dragtarget2 {};
|
||||
PluginList->SetDropTarget (
|
||||
dragtarget2 = safenew ExtImportPrefsDropTarget(
|
||||
dragtext2 = safenew wxTextDataObject(wxT(""))
|
||||
)
|
||||
);
|
||||
dragtarget2->SetPrefs (this);
|
||||
|
||||
PluginList->SetColumnWidth (0, wxLIST_AUTOSIZE_USEHEADER);
|
||||
|
||||
ExtImportItems *items = Importer::Get().GetImportItems();
|
||||
|
@ -646,9 +655,9 @@ void ExtImportPrefs::OnRuleTableCellClick (wxGridEvent& event)
|
|||
event.Skip();
|
||||
}
|
||||
|
||||
ExtImportPrefsDropTarget::ExtImportPrefsDropTarget (wxDataObject *dataObject)
|
||||
ExtImportPrefsDropTarget::ExtImportPrefsDropTarget(wxDataObject *dataObject)
|
||||
: wxDropTarget(dataObject)
|
||||
{
|
||||
SetDataObject (dataObject);
|
||||
mPrefs = NULL;
|
||||
}
|
||||
|
||||
|
@ -779,11 +788,6 @@ void ExtImportPrefsDropTarget::OnLeave()
|
|||
{
|
||||
}
|
||||
|
||||
void ExtImportPrefsDropTarget::SetDataObject(wxDataObject* data)
|
||||
{
|
||||
this->m_dataObject = data;
|
||||
}
|
||||
|
||||
PrefsPanel *ExtImportPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
|
|
|
@ -30,14 +30,14 @@ class ShuttleGui;
|
|||
class ExtImportPrefsDropTarget final : public wxDropTarget
|
||||
{
|
||||
public:
|
||||
ExtImportPrefsDropTarget (wxDataObject *dataObject = 0);
|
||||
// Takes ownership of the argument
|
||||
ExtImportPrefsDropTarget(wxDataObject* dataObject = nullptr);
|
||||
~ExtImportPrefsDropTarget ();
|
||||
wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def);
|
||||
bool OnDrop(wxCoord x, wxCoord y);
|
||||
wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def);
|
||||
wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def);
|
||||
void OnLeave();
|
||||
void SetDataObject(wxDataObject* data);
|
||||
void SetPrefs (ExtImportPrefs *prefs);
|
||||
private:
|
||||
ExtImportPrefs *mPrefs;
|
||||
|
@ -86,10 +86,8 @@ class ExtImportPrefs final : public PrefsPanel
|
|||
wxButton *MoveFilterUp;
|
||||
wxButton *MoveFilterDown;
|
||||
|
||||
wxTextDataObject *dragtext1;
|
||||
wxTextDataObject *dragtext2;
|
||||
ExtImportPrefsDropTarget *dragtarget1;
|
||||
ExtImportPrefsDropTarget *dragtarget2;
|
||||
wxTextDataObject *dragtext1 {};
|
||||
wxTextDataObject *dragtext2 {};
|
||||
|
||||
bool mCreateTable;
|
||||
wxWindow *mDragFocus;
|
||||
|
|
|
@ -89,6 +89,8 @@ class ToolBar /* not final */ : public wxPanelWrapper
|
|||
|
||||
public:
|
||||
|
||||
using Holder = Destroy_ptr<ToolBar>;
|
||||
|
||||
ToolBar(int type, const wxString & label, const wxString & section, bool resizable = false);
|
||||
virtual ~ToolBar();
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
|
|||
mLeft = std::make_unique<wxRegion>( 3, &pt[0] );
|
||||
|
||||
// Create the indicator frame
|
||||
mIndicator = new wxFrame( NULL,
|
||||
mIndicator = FramePtr{ safenew wxFrame( NULL,
|
||||
wxID_ANY,
|
||||
wxEmptyString,
|
||||
wxDefaultPosition,
|
||||
|
@ -372,7 +372,8 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
|
|||
wxFRAME_SHAPED |
|
||||
wxNO_BORDER |
|
||||
wxFRAME_NO_TASKBAR |
|
||||
wxSTAY_ON_TOP );
|
||||
wxSTAY_ON_TOP )
|
||||
};
|
||||
|
||||
// Hook the creation event...only needed on GTK, but doesn't hurt for all
|
||||
mIndicator->Connect( wxEVT_CREATE,
|
||||
|
@ -409,20 +410,20 @@ ToolManager::ToolManager( AudacityProject *parent, wxWindow *topDockParent )
|
|||
mBotDock = safenew ToolDock( this, mParent, BotDockID );
|
||||
|
||||
// Create all of the toolbars
|
||||
mBars[ ToolsBarID ] = new ToolsToolBar();
|
||||
mBars[ TransportBarID ] = new ControlToolBar();
|
||||
mBars[ RecordMeterBarID ] = new MeterToolBar( parent, RecordMeterBarID );
|
||||
mBars[ PlayMeterBarID ] = new MeterToolBar( parent, PlayMeterBarID );
|
||||
mBars[ MeterBarID ] = new MeterToolBar( parent, MeterBarID );
|
||||
mBars[ EditBarID ] = new EditToolBar();
|
||||
mBars[ MixerBarID ] = new MixerToolBar();
|
||||
mBars[ TranscriptionBarID ] = new TranscriptionToolBar();
|
||||
mBars[ SelectionBarID ] = new SelectionBar();
|
||||
mBars[ DeviceBarID ] = new DeviceToolBar();
|
||||
mBars[ ToolsBarID ] = ToolBar::Holder{ safenew ToolsToolBar() };
|
||||
mBars[ TransportBarID ] = ToolBar::Holder{ safenew ControlToolBar() };
|
||||
mBars[ RecordMeterBarID ] = ToolBar::Holder{ safenew MeterToolBar( parent, RecordMeterBarID ) };
|
||||
mBars[ PlayMeterBarID ] = ToolBar::Holder{ safenew MeterToolBar( parent, PlayMeterBarID ) };
|
||||
mBars[ MeterBarID ] = ToolBar::Holder{ safenew MeterToolBar( parent, MeterBarID ) };
|
||||
mBars[ EditBarID ] = ToolBar::Holder{ safenew EditToolBar() };
|
||||
mBars[ MixerBarID ] = ToolBar::Holder{ safenew MixerToolBar() };
|
||||
mBars[ TranscriptionBarID ] = ToolBar::Holder{ safenew TranscriptionToolBar() };
|
||||
mBars[ SelectionBarID ] = ToolBar::Holder{ safenew SelectionBar() };
|
||||
mBars[ DeviceBarID ] = ToolBar::Holder{ safenew DeviceToolBar() };
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
mBars[SpectralSelectionBarID] = new SpectralSelectionBar();
|
||||
mBars[SpectralSelectionBarID] = ToolBar::Holder{ safenew SpectralSelectionBar() };
|
||||
#endif
|
||||
mBars[ ScrubbingBarID ] = new ScrubbingToolBar();
|
||||
mBars[ ScrubbingBarID ] = ToolBar::Holder{ safenew ScrubbingToolBar() };
|
||||
|
||||
// We own the timer
|
||||
mTimer.SetOwner( this );
|
||||
|
@ -462,9 +463,6 @@ ToolManager::~ToolManager()
|
|||
wxPaintEventHandler( ToolManager::OnIndicatorPaint ),
|
||||
NULL,
|
||||
this );
|
||||
|
||||
// Must destroy the window since it doesn't have a parent
|
||||
mIndicator->Destroy();
|
||||
}
|
||||
|
||||
// This table describes the default configuration of the toolbars as
|
||||
|
@ -511,11 +509,11 @@ void ToolManager::Reset()
|
|||
for ( const auto &entry : DefaultConfigTable )
|
||||
{
|
||||
int ndx = entry.barID;
|
||||
ToolBar *bar = mBars[ ndx ];
|
||||
ToolBar *bar = mBars[ ndx ].get();
|
||||
|
||||
ToolBarConfiguration::Position position {
|
||||
(entry.rightOf == NoBarID) ? nullptr : mBars[ entry.rightOf ],
|
||||
(entry.below == NoBarID) ? nullptr : mBars[ entry.below ]
|
||||
(entry.rightOf == NoBarID) ? nullptr : mBars[ entry.rightOf ].get(),
|
||||
(entry.below == NoBarID) ? nullptr : mBars[ entry.below ].get()
|
||||
};
|
||||
|
||||
wxWindow *floater;
|
||||
|
@ -612,7 +610,7 @@ void ToolManager::Reset()
|
|||
|
||||
void ToolManager::RegenerateTooltips()
|
||||
{
|
||||
for (auto bar : mBars) {
|
||||
for (const auto &bar : mBars) {
|
||||
if (bar)
|
||||
bar->RegenerateTooltips();
|
||||
}
|
||||
|
@ -645,7 +643,7 @@ void ToolManager::ReadConfig()
|
|||
// Load and apply settings for each bar
|
||||
for( ndx = 0; ndx < ToolBarCount; ndx++ )
|
||||
{
|
||||
ToolBar *bar = mBars[ ndx ];
|
||||
ToolBar *bar = mBars[ ndx ].get();
|
||||
//wxPoint Center = mParent->GetPosition() + (mParent->GetSize() * 0.33);
|
||||
//wxPoint Center(
|
||||
// wxSystemSettings::GetMetric( wxSYS_SCREEN_X ) /2 ,
|
||||
|
@ -808,7 +806,7 @@ void ToolManager::ReadConfig()
|
|||
bool deviceWasPositioned = false;
|
||||
for( int ord = 0; ord < (int) unordered[ dock ].GetCount(); ord++ )
|
||||
{
|
||||
ToolBar *t = mBars[ unordered[ dock ][ ord ] ];
|
||||
ToolBar *t = mBars[ unordered[ dock ][ ord ] ].get();
|
||||
|
||||
if (deviceWasPositioned &&
|
||||
t->GetType() == DeviceBarID)
|
||||
|
@ -837,7 +835,7 @@ void ToolManager::ReadConfig()
|
|||
|
||||
// Reposition the device toolbar, if it was docked above,
|
||||
// right of scrubbing
|
||||
const auto deviceToolBar = mBars[ DeviceBarID ];
|
||||
const auto deviceToolBar = mBars[ DeviceBarID ].get();
|
||||
if (deviceToolBar->GetDock() == mTopDock) {
|
||||
deviceToolBar->GetDock()->Undock(deviceToolBar);
|
||||
position = { t, nullptr };
|
||||
|
@ -889,7 +887,7 @@ void ToolManager::WriteConfig()
|
|||
// Save state of each bar
|
||||
for( ndx = 0; ndx < ToolBarCount; ndx++ )
|
||||
{
|
||||
ToolBar *bar = mBars[ ndx ];
|
||||
ToolBar *bar = mBars[ ndx ].get();
|
||||
|
||||
// Change to the bar subkey
|
||||
gPrefs->SetPath( bar->GetSection() );
|
||||
|
@ -920,13 +918,6 @@ void ToolManager::WriteConfig()
|
|||
gPrefs->SetPath( wxT("..") );
|
||||
}
|
||||
|
||||
// Kill the bars
|
||||
for( ndx = 0; ndx < ToolBarCount; ndx++ )
|
||||
{
|
||||
ToolBar *bar = mBars[ ndx ];
|
||||
bar->Destroy();
|
||||
}
|
||||
|
||||
// Restore original config path
|
||||
gPrefs->SetPath( oldpath );
|
||||
gPrefs->Flush();
|
||||
|
@ -937,7 +928,7 @@ void ToolManager::WriteConfig()
|
|||
//
|
||||
ToolBar *ToolManager::GetToolBar( int type ) const
|
||||
{
|
||||
return mBars[ type ];
|
||||
return mBars[ type ].get();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -980,7 +971,7 @@ bool ToolManager::IsDocked( int type )
|
|||
//
|
||||
bool ToolManager::IsVisible( int type )
|
||||
{
|
||||
ToolBar *t = mBars[ type ];
|
||||
ToolBar *t = mBars[ type ].get();
|
||||
|
||||
return t->IsVisible();
|
||||
|
||||
|
@ -1010,7 +1001,7 @@ void ToolManager::ShowHide( int type )
|
|||
//
|
||||
void ToolManager::Expose( int type, bool show )
|
||||
{
|
||||
ToolBar *t = mBars[ type ];
|
||||
ToolBar *t = mBars[ type ].get();
|
||||
|
||||
// Handle docked and floaters differently
|
||||
if( t->IsDocked() )
|
||||
|
@ -1040,7 +1031,7 @@ void ToolManager::UpdatePrefs()
|
|||
{
|
||||
for( int ndx = 0; ndx < ToolBarCount; ndx++ )
|
||||
{
|
||||
ToolBar *bar = mBars[ ndx ];
|
||||
ToolBar *bar = mBars[ ndx ].get();
|
||||
if( bar )
|
||||
{
|
||||
bar->UpdatePrefs();
|
||||
|
@ -1302,7 +1293,7 @@ void ToolManager::OnGrabber( GrabberEvent & event )
|
|||
return HandleEscapeKey();
|
||||
|
||||
// Remember which bar we're dragging
|
||||
mDragBar = mBars[ event.GetId() ];
|
||||
mDragBar = mBars[ event.GetId() ].get();
|
||||
|
||||
// Remember state, in case of ESCape key later
|
||||
if (mDragBar->IsDocked()) {
|
||||
|
|
|
@ -97,7 +97,8 @@ class ToolManager final : public wxEvtHandler
|
|||
wxPoint mLastPos;
|
||||
wxRect mBarPos;
|
||||
|
||||
wxFrame *mIndicator;
|
||||
using FramePtr = Destroy_ptr<wxFrame>;
|
||||
FramePtr mIndicator;
|
||||
std::unique_ptr<wxRegion> mLeft, mDown;
|
||||
wxRegion *mCurrent;
|
||||
|
||||
|
@ -111,7 +112,7 @@ class ToolManager final : public wxEvtHandler
|
|||
ToolDock *mTopDock;
|
||||
ToolDock *mBotDock;
|
||||
|
||||
ToolBar *mBars[ ToolBarCount ];
|
||||
ToolBar::Holder mBars[ ToolBarCount ];
|
||||
|
||||
wxPoint mPrevPosition {};
|
||||
ToolDock *mPrevDock {};
|
||||
|
|
Loading…
Reference in New Issue