From 9fcaa83b7d8d123e21bf2dd6d283bc6a121213b8 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 13 Nov 2017 12:34:37 +0100 Subject: [PATCH] Library Manager: fixed a memleak in LIB_EDIT_FRAME::OnCreateNewPart() --- eeschema/libedit.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index 2ee3bcdc25..260ce97723 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -353,39 +353,38 @@ void LIB_EDIT_FRAME::OnCreateNewPart( wxCommandEvent& event ) return; } - LIB_PART* new_part = new LIB_PART( name ); - m_aliasName = new_part->GetName(); + LIB_PART new_part( name ); // do not create part on the heap, it will be buffered soon + m_aliasName = name; + new_part.GetReferenceField().SetText( dlg.GetReference() ); + new_part.SetUnitCount( dlg.GetUnitCount() ); - new_part->GetReferenceField().SetText( dlg.GetReference() ); - new_part->SetUnitCount( dlg.GetUnitCount() ); - - // Initialize new_part->m_TextInside member: + // Initialize new_part.m_TextInside member: // if 0, pin text is outside the body (on the pin) // if > 0, pin text is inside the body - new_part->SetConversion( dlg.GetAlternateBodyStyle() ); + new_part.SetConversion( dlg.GetAlternateBodyStyle() ); SetShowDeMorgan( dlg.GetAlternateBodyStyle() ); if( dlg.GetPinNameInside() ) { - new_part->SetPinNameOffset( dlg.GetPinTextPosition() ); + new_part.SetPinNameOffset( dlg.GetPinTextPosition() ); - if( new_part->GetPinNameOffset() == 0 ) - new_part->SetPinNameOffset( 1 ); + if( new_part.GetPinNameOffset() == 0 ) + new_part.SetPinNameOffset( 1 ); } else { - new_part->SetPinNameOffset( 0 ); + new_part.SetPinNameOffset( 0 ); } - ( dlg.GetPowerSymbol() ) ? new_part->SetPower() : new_part->SetNormal(); - new_part->SetShowPinNumbers( dlg.GetShowPinNumber() ); - new_part->SetShowPinNames( dlg.GetShowPinName() ); - new_part->LockUnits( dlg.GetLockItems() ); + ( dlg.GetPowerSymbol() ) ? new_part.SetPower() : new_part.SetNormal(); + new_part.SetShowPinNumbers( dlg.GetShowPinNumber() ); + new_part.SetShowPinNames( dlg.GetShowPinName() ); + new_part.LockUnits( dlg.GetLockItems() ); if( dlg.GetUnitCount() < 2 ) - new_part->LockUnits( false ); + new_part.LockUnits( false ); - m_libMgr->UpdatePart( new_part, lib ); + m_libMgr->UpdatePart( &new_part, lib ); loadPart( name, lib, 1 ); }