When saving footprint to library don't detach from board too early.

In particular, make sure it's been flipped to the front layer first.
We need to know the layers to do the flip.

Fixes https://gitlab.com/kicad/code/kicad/issues/7780
This commit is contained in:
Jeff Young 2021-03-03 14:36:06 +00:00
parent 62f1111c0b
commit fcb9af2b12
1 changed files with 4 additions and 2 deletions

View File

@ -2399,8 +2399,7 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFoot
// I need my own copy for the cache
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aFootprint->Clone() );
// It should have no parent, orientation should be zero, and it should be on the front layer.
footprint->SetParent( nullptr );
// It's orientation should be zero and it should be on the front layer.
footprint->SetOrientation( 0 );
if( footprint->GetLayer() != F_Cu )
@ -2413,6 +2412,9 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFoot
footprint->Flip( footprint->GetPosition(), false );
}
// Detach it from the board
footprint->SetParent( nullptr );
wxLogTrace( traceKicadPcbPlugin, wxT( "Creating s-expr footprint file '%s'." ), fullPath );
footprints.insert( footprintName, new FP_CACHE_ITEM( footprint, WX_FILENAME( fn.GetPath(), fullName ) ) );
m_cache->Save( footprint );