diff --git a/common/plugins/eagle/eagle_parser.h b/common/plugins/eagle/eagle_parser.h index 30457f86b4..f9fb7f5a2d 100644 --- a/common/plugins/eagle/eagle_parser.h +++ b/common/plugins/eagle/eagle_parser.h @@ -47,7 +47,6 @@ struct EPART; struct ETEXT; typedef std::unordered_map NODE_MAP; -typedef std::map FOOTPRINT_MAP; typedef std::map EINSTANCE_MAP; typedef std::map> EPART_MAP; diff --git a/pcbnew/plugins/eagle/eagle_plugin.cpp b/pcbnew/plugins/eagle/eagle_plugin.cpp index 87a6feb5d4..b37be9f712 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.cpp +++ b/pcbnew/plugins/eagle/eagle_plugin.cpp @@ -410,8 +410,8 @@ std::vector EAGLE_PLUGIN::GetImportedCachedLibraryFootprints() { std::vector retval; - for( std::pair fp : m_templates ) - retval.push_back( static_cast( fp.second->Clone() ) ); + for( const auto& [ name, footprint ] : m_templates ) + retval.push_back( static_cast( footprint->Clone() ) ); return retval; } @@ -1093,7 +1093,7 @@ void EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLib, const wxString* aLibName ) FOOTPRINT* footprint = makeFootprint( package, pack_ref ); // add the templating FOOTPRINT to the FOOTPRINT template factory "m_templates" - std::pair r = m_templates.insert( { key, footprint} ); + auto r = m_templates.insert( { key, footprint } ); if( !r.second /* && !( m_props && m_props->Value( "ignore_duplicates" ) ) */ ) { @@ -1173,8 +1173,7 @@ void EAGLE_PLUGIN::loadElements( wxXmlNode* aElements ) m_xpath->Value( e.name.c_str() ); wxString pkg_key = makeKey( e.library, e.package ); - - FOOTPRINT_MAP::const_iterator it = m_templates.find( pkg_key ); + auto it = m_templates.find( pkg_key ); if( it == m_templates.end() ) { @@ -2485,8 +2484,11 @@ void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, PAD* aPad ) const void EAGLE_PLUGIN::deleteTemplates() { - for( auto& t : m_templates ) - delete t.second; + for( const auto& [ name, footprint ] : m_templates ) + { + footprint->SetParent( nullptr ); + delete footprint; + } m_templates.clear(); } @@ -3173,8 +3175,8 @@ void EAGLE_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxS // Some of the files may have been parsed correctly so we want to add the valid files to // the library. - for( FOOTPRINT_MAP::const_iterator it = m_templates.begin(); it != m_templates.end(); ++it ) - aFootprintNames.Add( it->first ); + for( const auto& [ name, footprint ] : m_templates ) + aFootprintNames.Add( name ); if( !errorMsg.IsEmpty() && !aBestEfforts ) THROW_IO_ERROR( errorMsg ); @@ -3187,7 +3189,7 @@ FOOTPRINT* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath, { init( aProperties ); cacheLib( aLibraryPath ); - FOOTPRINT_MAP::const_iterator it = m_templates.find( aFootprintName ); + auto it = m_templates.find( aFootprintName ); if( it == m_templates.end() ) return nullptr; diff --git a/pcbnew/plugins/eagle/eagle_plugin.h b/pcbnew/plugins/eagle/eagle_plugin.h index f396b03964..f77e02aa9a 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.h +++ b/pcbnew/plugins/eagle/eagle_plugin.h @@ -332,10 +332,11 @@ private: NET_MAP m_pads_to_nets; ///< net list - FOOTPRINT_MAP m_templates; ///< is part of a FOOTPRINT factory that operates using copy - ///< construction. - ///< lookup key is either libname.packagename or simply - ///< packagename if FootprintLoad() or FootprintEnumberate() + std::map m_templates; ///< is part of a FOOTPRINT factory that operates + ///< using copy construction. + ///< lookup key is either libname.packagename or + ///< simply packagename if FootprintLoad() or + ///< FootprintEnumberate() const STRING_UTF8_MAP* m_props; ///< passed via Save() or Load(), no ownership, may be NULL. BOARD* m_board; ///< which BOARD is being worked on, no ownership here