Fix some memory leaks

Some elements of modules and boards were not deleted, so memory
was being leaked on some library loads and single-instance
pcbnew usage.
This commit is contained in:
Ian McInerney 2019-08-11 22:30:33 +02:00 committed by Wayne Stambaugh
parent 7bb046c0a5
commit d170243d61
3 changed files with 37 additions and 0 deletions

View File

@ -165,6 +165,13 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& titl
KICAD_MANAGER_FRAME::~KICAD_MANAGER_FRAME()
{
// Ensure there are no active tools
if( m_toolManager )
m_toolManager->DeactivateTool();
delete m_actions;
delete m_toolManager;
m_auimgr.UnInit();
}

View File

@ -146,9 +146,28 @@ BOARD::~BOARD()
Delete( area_to_remove );
}
// Clean up the owned elements
DeleteMARKERs();
DeleteZONEOutlines();
// Delete the modules
for( auto m : m_modules )
delete m;
m_modules.clear();
// Delete the tracks
for( auto t : m_tracks )
delete t;
m_tracks.clear();
// Delete the drawings
for (auto d : m_drawings )
delete d;
m_drawings.clear();
delete m_CurrentZoneContour;
m_CurrentZoneContour = NULL;
}

View File

@ -142,9 +142,20 @@ MODULE::MODULE( const MODULE& aModule ) :
MODULE::~MODULE()
{
// Clean up the owned elements
delete m_Reference;
delete m_Value;
delete m_initial_comments;
for( auto p : m_pads )
delete p;
m_pads.clear();
for( auto d : m_drawings )
delete d;
m_drawings.clear();
}