From db66e16f71cb8362b8279e9a1ee84f5633277c7e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 23 Oct 2020 17:56:15 +0200 Subject: [PATCH] SymbolEditor: Ask to save local edits in schematic on symbol editor window closure Previously, Asking for save, cancel... was made for a symbol coming from lib but not when the symbol come from the schematic editor. Fixes #6132 https://gitlab.com/kicad/code/kicad/issues/6132 --- eeschema/libedit/lib_edit_frame.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index e388e77568..5ab05d6550 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -28,7 +28,6 @@ #include #include #include -//#include #include #include #include @@ -457,6 +456,27 @@ bool LIB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent ) return false; } + if( m_isSymbolFromSchematic && IsContentModified() ) + { + SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false ); + + switch( UnsavedChangesDialog( this, + _( "Save changes to schematic before closing?" ), + nullptr ) ) + { + case wxID_YES: + if( schframe && GetCurPart() ) // Should be always the case + schframe->UpdateSymbolFromEditor( *GetCurPart() ); + + return true; + + case wxID_NO: return true; + + default: + case wxID_CANCEL: return false; + } + } + if( !saveAllLibraries( true ) ) { return false;