Fix some leaking objects identified by PVS Studio V773

(cherry picked from commit a7ebfc31f9)
This commit is contained in:
Marek Roszko 2022-02-05 11:15:10 -05:00 committed by Mark Roszko
parent c875af48e7
commit b2c99dd953
2 changed files with 9 additions and 8 deletions

View File

@ -217,7 +217,8 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const wxPoint&
std::vector<std::vector<PCB_TEXT*>> texts; std::vector<std::vector<PCB_TEXT*>> texts;
// Style : Header // Style : Header
PCB_TEXT* headStyle = new PCB_TEXT( static_cast<FOOTPRINT*>( m_frame->GetModel() ) ); std::unique_ptr<PCB_TEXT> headStyle =
std::make_unique<PCB_TEXT>( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
headStyle->SetLayer( Eco1_User ); headStyle->SetLayer( Eco1_User );
headStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) ); headStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) );
headStyle->SetTextThickness( Millimeter2iu( 0.3 ) ); headStyle->SetTextThickness( Millimeter2iu( 0.3 ) );
@ -228,7 +229,8 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawSpecificationStackup( const wxPoint&
headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
// Style : data // Style : data
PCB_TEXT* dataStyle = new PCB_TEXT( static_cast<FOOTPRINT*>( m_frame->GetModel() ) ); std::unique_ptr<PCB_TEXT> dataStyle =
std::make_unique<PCB_TEXT>( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
dataStyle->SetLayer( Eco1_User ); dataStyle->SetLayer( Eco1_User );
dataStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) ); dataStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) );
dataStyle->SetTextThickness( Millimeter2iu( 0.1 ) ); dataStyle->SetTextThickness( Millimeter2iu( 0.1 ) );
@ -382,7 +384,8 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint&
wxPoint cursorPos = aOrigin; wxPoint cursorPos = aOrigin;
// Style : Section header // Style : Section header
PCB_TEXT* headStyle = new PCB_TEXT( static_cast<FOOTPRINT*>( m_frame->GetModel() ) ); std::unique_ptr<PCB_TEXT> headStyle =
std::make_unique<PCB_TEXT>( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
headStyle->SetLayer( Eco1_User ); headStyle->SetLayer( Eco1_User );
headStyle->SetTextSize( wxSize( Millimeter2iu( 2.0 ), Millimeter2iu( 2.0 ) ) ); headStyle->SetTextSize( wxSize( Millimeter2iu( 2.0 ), Millimeter2iu( 2.0 ) ) );
headStyle->SetTextThickness( Millimeter2iu( 0.4 ) ); headStyle->SetTextThickness( Millimeter2iu( 0.4 ) );
@ -392,7 +395,8 @@ std::vector<BOARD_ITEM*> DRAWING_TOOL::DrawBoardCharacteristics( const wxPoint&
headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); headStyle->SetVertJustify( GR_TEXT_VJUSTIFY_TOP );
// Style : Data // Style : Data
PCB_TEXT* dataStyle = new PCB_TEXT( static_cast<FOOTPRINT*>( m_frame->GetModel() ) ); std::unique_ptr<PCB_TEXT> dataStyle =
std::make_unique<PCB_TEXT>( static_cast<FOOTPRINT*>( m_frame->GetModel() ) );
dataStyle->SetLayer( Eco1_User ); dataStyle->SetLayer( Eco1_User );
dataStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) ); dataStyle->SetTextSize( wxSize( Millimeter2iu( 1.5 ), Millimeter2iu( 1.5 ) ) );
dataStyle->SetTextThickness( Millimeter2iu( 0.2 ) ); dataStyle->SetTextThickness( Millimeter2iu( 0.2 ) );

View File

@ -384,18 +384,16 @@ bool KICADPCB::parseRect( SEXPR::SEXPR* data )
bool KICADPCB::parsePolygon( SEXPR::SEXPR* data ) bool KICADPCB::parsePolygon( SEXPR::SEXPR* data )
{ {
KICADCURVE* poly = new KICADCURVE(); std::unique_ptr<KICADCURVE> poly = std::make_unique<KICADCURVE>();
if( !poly->Read( data, CURVE_POLYGON ) ) if( !poly->Read( data, CURVE_POLYGON ) )
{ {
delete poly;
return false; return false;
} }
// reject any curves not on the Edge.Cuts layer // reject any curves not on the Edge.Cuts layer
if( poly->GetLayer() != LAYER_EDGE ) if( poly->GetLayer() != LAYER_EDGE )
{ {
delete poly;
return true; return true;
} }
@ -418,7 +416,6 @@ bool KICADPCB::parsePolygon( SEXPR::SEXPR* data )
seg->m_end = pts.front(); seg->m_end = pts.front();
m_curves.push_back( seg ); m_curves.push_back( seg );
return true; return true;
} }