Defensive code to prevent lookup of stale parent board.

Fixes https://gitlab.com/kicad/code/kicad/issues/6618
This commit is contained in:
Jeff Young 2020-12-04 12:14:07 +00:00
parent fd5e1fbdd4
commit f3e1ac8dbe
5 changed files with 25 additions and 8 deletions

View File

@ -155,14 +155,11 @@ FOOTPRINT::FOOTPRINT( const FOOTPRINT& aFootprint ) :
m_3D_Drawings = aFootprint.m_3D_Drawings;
m_doc = aFootprint.m_doc;
m_keywords = aFootprint.m_keywords;
m_keywords = aFootprint.m_keywords;
m_properties = aFootprint.m_properties;
m_arflag = 0;
// Ensure auxiliary data is up to date
CalculateBoundingBox();
m_initial_comments = aFootprint.m_initial_comments ?
new wxArrayString( *aFootprint.m_initial_comments ) : nullptr;
}

View File

@ -2847,7 +2847,9 @@ FOOTPRINT* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
return NULL;
// Return a copy of the template
return (FOOTPRINT*) it->second->Duplicate();
FOOTPRINT* copy = (FOOTPRINT*) it->second->Duplicate();
copy->SetParent( nullptr );
return copy;
}

View File

@ -936,7 +936,15 @@ FOOTPRINT* GPCB_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
const PROPERTIES* aProperties )
{
const FOOTPRINT* footprint = getFootprint( aLibraryPath, aFootprintName, aProperties, true );
return footprint ? (FOOTPRINT*) footprint->Duplicate() : nullptr;
if( footprint )
{
FOOTPRINT* copy = (FOOTPRINT*) footprint->Duplicate();
copy->SetParent( nullptr );
return copy;
}
return nullptr;
}

View File

@ -2238,7 +2238,15 @@ FOOTPRINT* PCB_IO::FootprintLoad( const wxString& aLibraryPath, const wxString&
const PROPERTIES* aProperties )
{
const FOOTPRINT* footprint = getFootprint( aLibraryPath, aFootprintName, aProperties, true );
return footprint ? (FOOTPRINT*) footprint->Duplicate() : nullptr;
if( footprint )
{
FOOTPRINT* copy = (FOOTPRINT*) footprint->Duplicate();
copy->SetParent( nullptr );
return copy;
}
return nullptr;
}

View File

@ -3325,7 +3325,9 @@ FOOTPRINT* LEGACY_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
}
// Return copy of already loaded FOOTPRINT
return (FOOTPRINT*) it->second->Duplicate();
FOOTPRINT* copy = (FOOTPRINT*) it->second->Duplicate();
copy->SetParent( nullptr );
return copy;
}