Fix memory leak and re-code non-memory-leak so Coverity can understand it.
This commit is contained in:
parent
e39c0b20ea
commit
9fa8b9e49f
|
@ -180,17 +180,18 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const TOOL_EVENT& aTool,
|
|||
}
|
||||
else
|
||||
{
|
||||
auto oldFlags = newItem->GetFlags();
|
||||
newItem->ClearFlags();
|
||||
BOARD_ITEM* newBoardItem = newItem.release();
|
||||
EDA_ITEM_FLAGS oldFlags = newBoardItem->GetFlags();
|
||||
|
||||
if( !aPlacer->PlaceItem( newItem.get(), commit ) )
|
||||
newBoardItem->ClearFlags();
|
||||
|
||||
if( !aPlacer->PlaceItem( newBoardItem, commit ) )
|
||||
{
|
||||
newItem->SetFlags( oldFlags );
|
||||
newBoardItem->SetFlags( oldFlags );
|
||||
continue;
|
||||
}
|
||||
|
||||
preview.Clear();
|
||||
newItem.release();
|
||||
commit.Push( aCommitMessage );
|
||||
|
||||
controls()->CaptureCursor( false );
|
||||
|
@ -244,7 +245,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const TOOL_EVENT& aTool,
|
|||
else if( evt->IsAction( &ACTIONS::refreshPreview ) )
|
||||
{
|
||||
preview.Clear();
|
||||
newItem.release();
|
||||
newItem.reset();
|
||||
|
||||
makeNewItem( cursorPos );
|
||||
aPlacer->SnapItem( newItem.get() );
|
||||
|
|
Loading…
Reference in New Issue