From 176b1a0fd5a84d1f390254dc8acc092e06d970a0 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 19 Jul 2019 19:06:16 +0200 Subject: [PATCH] FP editor: fix crash when trying to save a footprint (Ctrl+S) when no footprint loaded. --- pcbnew/footprint_editor_utils.cpp | 3 +++ pcbnew/footprint_libraries_utils.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 957205313b..f48eaee24f 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -255,6 +255,9 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_MODEDIT_SAVE: + if( !GetBoard()->GetFirstModule() ) // no loaded footprint + break; + if( GetTargetFPID() == GetLoadedFPID() ) { if( SaveFootprint( GetBoard()->GetFirstModule() ) ) diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 970cf45e71..a3a988de15 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -706,6 +706,9 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& bool FOOTPRINT_EDIT_FRAME::SaveFootprint( MODULE* aModule ) { + if( !aModule ) // Happen if no footprint loaded + return false; + wxString libraryName = aModule->GetFPID().GetLibNickname(); wxString footprintName = aModule->GetFPID().GetLibItemName(); bool nameChanged = m_footprintNameWhenLoaded != footprintName;