Don't save schematic symbol back to lib manager.
Also, since it doesn't get saved, changing symbols will lose any edits. Make sure to ask the user first. Fixes https://gitlab.com/kicad/code/kicad/issues/10767
This commit is contained in:
parent
1db8229068
commit
16acba34d3
|
@ -811,6 +811,8 @@ SYMBOL_LIBRARY_MANAGER& SYMBOL_EDIT_FRAME::GetLibManager()
|
|||
void SYMBOL_EDIT_FRAME::OnModify()
|
||||
{
|
||||
GetScreen()->SetContentModified();
|
||||
|
||||
if( !IsSymbolFromSchematic() )
|
||||
storeCurrentSymbol();
|
||||
|
||||
m_treePane->GetLibTree()->RefreshLibTree();
|
||||
|
|
|
@ -233,6 +233,24 @@ wxString SYMBOL_EDIT_FRAME::SelectLibraryFromList()
|
|||
bool SYMBOL_EDIT_FRAME::saveCurrentSymbol()
|
||||
{
|
||||
if( GetCurSymbol() )
|
||||
{
|
||||
if( IsSymbolFromSchematic() )
|
||||
{
|
||||
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
|
||||
|
||||
if( !schframe ) // happens when the schematic editor has been closed
|
||||
{
|
||||
DisplayErrorMessage( this, _( "No schematic currently open." ) );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
schframe->SaveSymbolToSchematic( *m_symbol, m_schematicSymbolUUID );
|
||||
GetScreen()->SetContentModified( false );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LIB_ID libId = GetCurSymbol()->GetLibId();
|
||||
const wxString& libName = libId.GetLibNickname();
|
||||
|
@ -244,6 +262,7 @@ bool SYMBOL_EDIT_FRAME::saveCurrentSymbol()
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -251,14 +270,15 @@ bool SYMBOL_EDIT_FRAME::saveCurrentSymbol()
|
|||
|
||||
bool SYMBOL_EDIT_FRAME::LoadSymbol( const LIB_ID& aLibId, int aUnit, int aConvert )
|
||||
{
|
||||
if( !IsSymbolFromSchematic()
|
||||
&& GetCurSymbol() && GetCurSymbol()->GetLibId() == aLibId
|
||||
&& GetUnit() == aUnit && GetConvert() == aConvert )
|
||||
if( GetCurSymbol() && !IsSymbolFromSchematic()
|
||||
&& GetCurSymbol()->GetLibId() == aLibId
|
||||
&& GetUnit() == aUnit
|
||||
&& GetConvert() == aConvert )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( GetScreen()->IsContentModified() && GetCurSymbol() )
|
||||
if( GetCurSymbol() && IsSymbolFromSchematic() && GetScreen()->IsContentModified() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this, _( "The current symbol has been modified. Save changes?" ),
|
||||
[&]() -> bool
|
||||
|
@ -986,16 +1006,25 @@ void SYMBOL_EDIT_FRAME::RevertAll()
|
|||
|
||||
void SYMBOL_EDIT_FRAME::LoadSymbol( const wxString& aAlias, const wxString& aLibrary, int aUnit )
|
||||
{
|
||||
if( GetCurSymbol() && IsSymbolFromSchematic() && GetScreen()->IsContentModified() )
|
||||
{
|
||||
if( !HandleUnsavedChanges( this, _( "The current symbol has been modified. Save changes?" ),
|
||||
[&]() -> bool
|
||||
{
|
||||
return saveCurrentSymbol();
|
||||
} ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LIB_SYMBOL* symbol = m_libMgr->GetBufferedSymbol( aAlias, aLibrary );
|
||||
|
||||
if( !symbol )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( _( "Symbol %s not found in library '%s'." ),
|
||||
DisplayError( this, wxString::Format( _( "Symbol %s not found in library '%s'." ),
|
||||
aAlias,
|
||||
aLibrary );
|
||||
DisplayError( this, msg );
|
||||
aLibrary ) );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue