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
This commit is contained in:
jean-pierre charras 2020-10-23 17:56:15 +02:00
parent b7c2d64333
commit db66e16f71
1 changed files with 21 additions and 1 deletions

View File

@ -28,7 +28,6 @@
#include <confirm.h> #include <confirm.h>
#include <eeschema_id.h> #include <eeschema_id.h>
#include <eeschema_settings.h> #include <eeschema_settings.h>
//#include <general.h>
#include <kiface_i.h> #include <kiface_i.h>
#include <kiplatform/app.h> #include <kiplatform/app.h>
#include <kiway_express.h> #include <kiway_express.h>
@ -457,6 +456,27 @@ bool LIB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
return false; 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 ) ) if( !saveAllLibraries( true ) )
{ {
return false; return false;