Fix various memory leaks exposed by qa_eeschema

This commit is contained in:
Jon Evans 2021-01-18 22:40:58 -05:00
parent 4052b2153a
commit 1491330596
9 changed files with 35 additions and 2 deletions

View File

@ -702,6 +702,9 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl )
}
}
for( NET_RECORD* record : nets )
delete record;
return xnets;
}

View File

@ -215,7 +215,7 @@ public:
SCH_ITEM( const SCH_ITEM& aItem );
~SCH_ITEM();
virtual ~SCH_ITEM();
virtual wxString GetClass() const override
{

View File

@ -145,6 +145,8 @@ public:
SCH_SHEET_PATH& operator=( const SCH_SHEET_PATH& aOther );
~SCH_SHEET_PATH() = default;
/// Forwarded method from std::vector
SCH_SHEET* at( size_t aIndex ) const { return m_sheets.at( aIndex ); }

View File

@ -50,6 +50,11 @@ public:
m_schematic.SetProject( &m_manager.Prj() );
}
virtual ~TEST_NETLIST_EXPORTER_PSPICE_SIM()
{
m_schematic.Reset();
}
SETTINGS_MANAGER m_manager;
SCHEMATIC m_schematic;

View File

@ -34,7 +34,9 @@
*/
BOOST_AUTO_TEST_CASE( FindPlugin )
{
BOOST_CHECK_NE( SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE ), nullptr );
SCH_PLUGIN* pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_EAGLE );
BOOST_CHECK_NE( pi, nullptr );
SCH_IO_MGR::ReleasePlugin( pi );
}
@ -66,4 +68,6 @@ BOOST_AUTO_TEST_CASE( Load )
// This doesn't work with a null KiWay.
// const SCH_SHEET* sheet = pi->Load( fn.GetFullPath(), nullptr );
// BOOST_CHECK_NE( nullptr, sheet );
SCH_IO_MGR::ReleasePlugin( pi );
}

View File

@ -42,6 +42,12 @@ public:
m_pi = SCH_IO_MGR::FindPlugin( SCH_IO_MGR::SCH_KICAD );
}
virtual ~TEST_NETLISTS_FIXTURE()
{
m_schematic.Reset();
SCH_IO_MGR::ReleasePlugin( m_pi );
}
void loadSchematic( const wxString& aBaseName );
wxString getNetlistFileName( bool aTest = false );
@ -196,6 +202,7 @@ void TEST_NETLISTS_FIXTURE::compareNetlists()
void TEST_NETLISTS_FIXTURE::cleanup()
{
wxRemoveFile( getNetlistFileName( true ) );
m_schematic.Reset();
}

View File

@ -174,6 +174,9 @@ BOOST_AUTO_TEST_CASE( Junctions )
}
BOOST_CHECK_EQUAL( count, 51 );
for( SCH_ITEM* item : m_tree )
delete item;
}
BOOST_AUTO_TEST_CASE( MixedElements )
@ -239,6 +242,9 @@ BOOST_AUTO_TEST_CASE( MixedElements )
}
BOOST_CHECK_EQUAL( count, 1 );
for( SCH_ITEM* item : m_tree )
delete item;
}
// This tests the case where the tree has no branches but we want to iterator over a subset
@ -269,6 +275,9 @@ BOOST_AUTO_TEST_CASE( SingleElementTree )
}
BOOST_CHECK_EQUAL( count, 1 );
for( SCH_ITEM* item : m_tree )
delete item;
}
BOOST_AUTO_TEST_SUITE_END()

View File

@ -139,6 +139,8 @@ BOOST_AUTO_TEST_CASE( AddPins )
BOOST_CHECK_EQUAL( m_sheet.HasPins(), false );
BOOST_CHECK_EQUAL( m_sheet.HasPin( "pinname" ), false );
BOOST_CHECK_EQUAL( m_sheet.GetPin( pinPos ), nullptr );
delete &pinRef;
}
/**

View File

@ -40,6 +40,7 @@ public:
virtual ~TEST_SCH_SHEET_LIST_FIXTURE()
{
m_schematic.Reset();
delete m_pi;
}