Fix bug in legacy schematic I/O plugin.
Move adding LIB_PART to library until the part is fully parse. The problem was unique_ptr was cleaning up the part when an exception was thrown during parsing causing a double free when the cache was deleted. Add missing try/catch block when loading the cache library during an append schematic operation. Fixes lp:1663869 https://bugs.launchpad.net/kicad/+bug/1663869
This commit is contained in:
parent
eb06b35852
commit
e8cf4f0724
|
@ -548,7 +548,8 @@ const wxString PART_LIBS::CacheName( const wxString& aFullProjectFilename )
|
|||
}
|
||||
|
||||
|
||||
void PART_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress ) throw( IO_ERROR, boost::bad_pointer )
|
||||
void PART_LIBS::LoadAllLibraries( PROJECT* aProject, bool aShowProgress )
|
||||
throw( IO_ERROR, boost::bad_pointer )
|
||||
{
|
||||
wxString filename;
|
||||
wxString libs_not_found;
|
||||
|
|
|
@ -397,8 +397,15 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
{
|
||||
PART_LIBS* libs = Prj().SchLibs();
|
||||
|
||||
if( PART_LIB* lib = libs->AddLibrary( cache_name ) )
|
||||
lib->SetCache();
|
||||
try
|
||||
{
|
||||
if( PART_LIB* lib = libs->AddLibrary( cache_name ) )
|
||||
lib->SetCache();
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( this, ioe.What() );
|
||||
}
|
||||
}
|
||||
|
||||
wxLogDebug( wxT( "Importing schematic " ) + fullFileName );
|
||||
|
|
|
@ -2382,10 +2382,6 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::loadPart( FILE_LINE_READER& aReader )
|
|||
value.SetVisible( false );
|
||||
}
|
||||
|
||||
// Add the root alias to the alias list.
|
||||
part->m_aliases.push_back( new LIB_ALIAS( name, part.get() ) );
|
||||
m_aliases[ part->GetName() ] = part->GetAlias( name );
|
||||
|
||||
LIB_FIELD& reference = part->GetReferenceField();
|
||||
|
||||
if( prefix == "~" )
|
||||
|
@ -2450,7 +2446,13 @@ LIB_PART* SCH_LEGACY_PLUGIN_CACHE::loadPart( FILE_LINE_READER& aReader )
|
|||
else if( strCompare( "$FPLIST", line, &line ) ) // Footprint filter list
|
||||
loadFootprintFilters( part, aReader );
|
||||
else if( strCompare( "ENDDEF", line, &line ) ) // End of part description
|
||||
{
|
||||
// Add the root alias to the alias list.
|
||||
part->m_aliases.push_back( new LIB_ALIAS( name, part.get() ) );
|
||||
m_aliases[ part->GetName() ] = part->GetAlias( name );
|
||||
|
||||
return part.release();
|
||||
}
|
||||
|
||||
line = aReader.ReadLine();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue