1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-14 08:36:27 +01:00

Sizers are owned by wxWindow objects when added, so use safenew, or...

... use unique_ptr in the interim between building them and adding.

This checks eliminates some naked news, which were not paired with deletes.
This commit is contained in:
Paul Licameli
2016-02-18 14:53:43 -05:00
parent c7d3ff7299
commit 1c07741d57
26 changed files with 1338 additions and 1233 deletions

View File

@@ -163,8 +163,7 @@ void ShuttleGuiBase::Init()
if( !mpSizer )
{
mpSizer = new wxBoxSizer( wxVERTICAL );
mpParent->SetSizer( mpSizer );
mpParent->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
}
PushSizer();
mpSizer->SetMinSize(250,100);
@@ -707,7 +706,7 @@ wxStaticBox * ShuttleGuiBase::StartStatic(const wxString &Str, int iProp)
Str );
pBox->SetLabel( Str );
pBox->SetName(wxStripMenuCodes(Str));
mpSubSizer = new wxStaticBoxSizer(
mpSubSizer = std::make_unique<wxStaticBoxSizer>(
pBox,
wxVERTICAL );
miSizerProp = iProp;
@@ -762,8 +761,7 @@ wxScrolledWindow * ShuttleGuiBase::StartScroller(int iStyle)
// create a sizer within the window...
mpParent = pScroller;
mpSizer = new wxBoxSizer( wxVERTICAL );
pScroller->SetSizer( mpSizer );
pScroller->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
PushSizer();
return pScroller;
}
@@ -810,8 +808,7 @@ wxPanel * ShuttleGuiBase::StartPanel(int iStyle)
// create a sizer within the window...
mpParent = pPanel;
mpSizer = new wxBoxSizer( wxVERTICAL );
pPanel->SetSizer( mpSizer );
pPanel->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
PushSizer();
return pPanel;
}
@@ -861,10 +858,9 @@ wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const wxString & Name )
SetProportions( 1 );
mpParent = pPage;
mpSizer = new wxBoxSizer( wxVERTICAL );
mpSizer->SetMinSize(250,500);
pPage->SetSizer( mpSizer );
// UpdateSizers();
pPage->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
mpSizer->SetMinSize(250, 500);
// UpdateSizers();
return pPage;
}
@@ -885,10 +881,9 @@ void ShuttleGuiBase::StartNotebookPage( const wxString & Name, wxNotebookPage *
SetProportions( 1 );
mpParent = pPage;
mpSizer = new wxBoxSizer( wxVERTICAL );
mpSizer->SetMinSize(250,500);
pPage->SetSizer( mpSizer );
// UpdateSizers();
pPage->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
mpSizer->SetMinSize(250, 500);
// UpdateSizers();
}
void ShuttleGuiBase::EndNotebookPage()
@@ -950,8 +945,7 @@ wxPanel * ShuttleGuiBase::StartInvisiblePanel()
// create a sizer within the window...
mpParent = pPanel;
mpSizer = new wxBoxSizer( wxVERTICAL );
pPanel->SetSizer( mpSizer );
pPanel->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL));
PushSizer();
return pPanel;
}
@@ -973,7 +967,7 @@ void ShuttleGuiBase::StartHorizontalLay( int PositionFlags, int iProp)
if( mShuttleMode != eIsCreating )
return;
miSizerProp=iProp;
mpSubSizer = new wxBoxSizer( wxHORIZONTAL );
mpSubSizer = std::make_unique<wxBoxSizer>( wxHORIZONTAL );
UpdateSizersCore( false, PositionFlags | wxALL );
}
@@ -989,7 +983,7 @@ void ShuttleGuiBase::StartVerticalLay(int iProp)
if( mShuttleMode != eIsCreating )
return;
miSizerProp=iProp;
mpSubSizer = new wxBoxSizer( wxVERTICAL );
mpSubSizer = std::make_unique<wxBoxSizer>( wxVERTICAL );
UpdateSizers();
}
@@ -1004,7 +998,7 @@ void ShuttleGuiBase::StartMultiColumn(int nCols, int PositionFlags)
{
if( mShuttleMode != eIsCreating )
return;
mpSubSizer = new wxFlexGridSizer( nCols );
mpSubSizer = std::make_unique<wxFlexGridSizer>( nCols );
UpdateSizersCore( false, PositionFlags | wxALL );
}
@@ -1935,16 +1929,16 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags)
{
// When adding sizers into sizers, don't add a border.
// unless it's a static box sizer.
if( wxDynamicCast( mpSubSizer, wxStaticBoxSizer ))
wxSizer *const pSubSizer = mpSubSizer.get();
if (wxDynamicCast(pSubSizer, wxStaticBoxSizer))
{
mpSizer->Add( mpSubSizer,miSizerProp, Flags , miBorder);
mpSizer->Add( mpSubSizer.release(), miSizerProp, Flags , miBorder);
}
else
{
mpSizer->Add( mpSubSizer,miSizerProp, Flags ,0);//miBorder);
mpSizer->Add( mpSubSizer.release(), miSizerProp, Flags ,0);//miBorder);
}
mpSizer = mpSubSizer;
mpSubSizer = NULL;
mpSizer = pSubSizer;
PushSizer();
}
mpLastWind = mpWind;
@@ -2116,7 +2110,7 @@ AttachableScrollBar * ShuttleGui::AddAttachableScrollBar( long style )
return pAttachableScrollBar;
}
wxSizer *CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra)
std::unique_ptr<wxSizer> CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra)
{
wxASSERT(parent != NULL); // To justify safenew
@@ -2136,7 +2130,7 @@ wxSizer *CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra)
}
wxButton *b = NULL;
wxStdDialogButtonSizer *bs = new wxStdDialogButtonSizer();
auto bs = std::make_unique<wxStdDialogButtonSizer>();
if( buttons & eOkButton )
{
@@ -2226,12 +2220,11 @@ wxSizer *CreateStdButtonSizer(wxWindow *parent, long buttons, wxWindow *extra)
bs->Insert( lastLastSpacer + 1, b, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, margin );
}
wxSizer * s;
s = new wxBoxSizer( wxVERTICAL );
s->Add( bs, 1, wxEXPAND | wxALL, 7 );
auto s = std::make_unique<wxBoxSizer>( wxVERTICAL );
s->Add( bs.release(), 1, wxEXPAND | wxALL, 7 );
s->Add( 0, 3 ); // a little extra space
return s;
return std::unique_ptr<wxSizer>{ s.release() };
}
void ShuttleGui::AddStandardButtons(long buttons, wxButton *extra)