From 0bcfb2c7df2dc37608983831cb6b2492772d507f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 19 May 2018 00:56:38 +0100 Subject: [PATCH] Don't write library name to footprint files. Fixes: lp:1772095 * https://bugs.launchpad.net/kicad/+bug/1772095 --- pcbnew/footprint_libraries_utils.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index f4c6beb7fb..79a687f606 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -663,6 +663,25 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& } +class LIBRARY_NAME_CLEARER +{ + MODULE* m_module; + LIB_ID m_savedFPID; + +public: + LIBRARY_NAME_CLEARER( MODULE* aModule ) + { + m_module = aModule; + m_savedFPID = aModule->GetFPID(); + m_module->SetFPID( LIB_ID( m_savedFPID.GetLibItemName() ) ); + } + ~LIBRARY_NAME_CLEARER() + { + m_module->SetFPID( m_savedFPID ); + } +}; + + bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( wxString activeLibrary, MODULE* aModule ) { if( aModule == NULL ) @@ -777,6 +796,8 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( wxString activeLibrary, MODUL module_exists = m != nullptr; delete m; + LIBRARY_NAME_CLEARER temp( aModule ); + // this always overwrites any existing footprint, but should yell on its // own if the library or footprint is not writable. tbl->FootprintSave( libraryName, aModule );