Save ModEdit's footprint ID rather than source.
This primarily keeps us from overriding "truth" with data that might not have even been saved when closing ModEdit. Fixes: lp:1752543 * https://bugs.launchpad.net/kicad/+bug/1752543
This commit is contained in:
parent
f1b48eb4f4
commit
308f28d2d4
|
@ -170,6 +170,8 @@ public:
|
|||
|
||||
PCB_LIB_NICKNAME,
|
||||
PCB_FOOTPRINT,
|
||||
PCB_FOOTPRINT_EDITOR_FPNAME,
|
||||
PCB_FOOTPRINT_EDITOR_NICKNAME,
|
||||
PCB_FOOTPRINT_VIEWER_FPNAME,
|
||||
PCB_FOOTPRINT_VIEWER_NICKNAME,
|
||||
|
||||
|
|
|
@ -409,57 +409,32 @@ const wxString FOOTPRINT_EDIT_FRAME::GetCurrentLib() const
|
|||
|
||||
void FOOTPRINT_EDIT_FRAME::retainLastFootprint()
|
||||
{
|
||||
PCB_IO pcb_io;
|
||||
MODULE* module = GetBoard()->m_Modules;
|
||||
|
||||
if( module )
|
||||
{
|
||||
pcb_io.Format( module );
|
||||
|
||||
wxString pretty = FROM_UTF8( pcb_io.GetStringOutput( true ).c_str() );
|
||||
|
||||
// save the footprint in the RSTRING facility.
|
||||
Prj().SetRString( PROJECT::PCB_FOOTPRINT, pretty );
|
||||
LIB_ID id = module->GetFPID();
|
||||
Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME, id.GetLibNickname() );
|
||||
Prj().SetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME, id.GetLibItemName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::restoreLastFootprint()
|
||||
{
|
||||
wxString pretty = Prj().GetRString( PROJECT::PCB_FOOTPRINT );
|
||||
const wxString& curFootprintName = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_FPNAME );
|
||||
const wxString& curNickname = Prj().GetRString( PROJECT::PCB_FOOTPRINT_EDITOR_NICKNAME );
|
||||
|
||||
if( !!pretty )
|
||||
if( curNickname.Length() && curFootprintName.Length() )
|
||||
{
|
||||
PCB_IO pcb_io;
|
||||
MODULE* module = NULL;
|
||||
LIB_ID id;
|
||||
id.SetLibNickname( curNickname );
|
||||
id.SetLibItemName( curFootprintName );
|
||||
|
||||
try
|
||||
{
|
||||
module = (MODULE*) pcb_io.Parse( pretty );
|
||||
}
|
||||
catch( const PARSE_ERROR& )
|
||||
{
|
||||
// unlikely to be a problem, since we produced the pretty string.
|
||||
wxLogError( "PARSE_ERROR" );
|
||||
}
|
||||
catch( const IO_ERROR& )
|
||||
{
|
||||
// unlikely to be a problem, since we produced the pretty string.
|
||||
wxLogError( "IO_ERROR" );
|
||||
}
|
||||
MODULE* module = loadFootprint( id );
|
||||
|
||||
if( module )
|
||||
{
|
||||
// assumes BOARD is empty.
|
||||
wxASSERT( GetBoard()->m_Modules == NULL );
|
||||
|
||||
// no idea, its monkey see monkey do. I would encapsulate this into
|
||||
// a member function if its actually necessary.
|
||||
module->SetParent( GetBoard() );
|
||||
module->SetLink( 0 );
|
||||
|
||||
GetBoard()->Add( module );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue