Eeschema: remove rogue calls to SCH_SCREEN::UpdateSymbolLinks().
SCH_SCREEN::UpdateSymbolLinks() should only be called when working with the legacy schematic file format. Add schematic symbol library symbol links should be set using SCH_COMPONENT::SetLibSymbol() which updates the symbol link and pin map accordingly. Change the schematic symbol LIB_ID edit dialog to properly use the new SCH_COMPONENT::SetLibSymbol() function.
This commit is contained in:
parent
5cf474e1c8
commit
a06fa22b8a
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -390,8 +390,6 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
case MAIL_SCH_GET_NETLIST:
|
||||
if( payload.find( "quiet-annotate" ) != std::string::npos )
|
||||
{
|
||||
SCH_SCREENS schematic;
|
||||
schematic.UpdateSymbolLinks();
|
||||
SCH_SHEET_LIST sheets( g_RootSheet );
|
||||
sheets.AnnotatePowerSymbols();
|
||||
AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, 0, false, false, true,
|
||||
|
@ -431,7 +429,6 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
|
|||
case MAIL_SCH_REFRESH:
|
||||
{
|
||||
SCH_SCREENS schematic;
|
||||
schematic.UpdateSymbolLinks();
|
||||
schematic.TestDanglingEnds();
|
||||
|
||||
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
||||
|
|
|
@ -29,12 +29,14 @@
|
|||
|
||||
|
||||
#include <fctsys.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_reference_list.h>
|
||||
#include <pgm_base.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <widgets/wx_grid.h>
|
||||
|
||||
#include <dialog_edit_components_libid_base.h>
|
||||
|
@ -289,12 +291,12 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* DIALOG_EDIT_COMPONENTS_LIBID is a dialog to globally edit the LIB_ID of groups if components
|
||||
* having the same initial LIB_ID.
|
||||
* this is useful when you want:
|
||||
* to move a symbol from a symbol library to another symbol library
|
||||
* Dialog to globally edit the #LIB_ID of groups if components having the same initial LIB_ID.
|
||||
*
|
||||
* This is useful when you want to:
|
||||
* * to move a symbol from a symbol library to another symbol library
|
||||
* to change the nickname of a library
|
||||
* globally replace the symbol used by a group of components by another symbol.
|
||||
* * globally replace the symbol used by a group of components by another symbol.
|
||||
*/
|
||||
class DIALOG_EDIT_COMPONENTS_LIBID : public DIALOG_EDIT_COMPONENTS_LIBID_BASE
|
||||
{
|
||||
|
@ -302,10 +304,11 @@ public:
|
|||
DIALOG_EDIT_COMPONENTS_LIBID( SCH_EDIT_FRAME* aParent );
|
||||
~DIALOG_EDIT_COMPONENTS_LIBID() override;
|
||||
|
||||
SCH_EDIT_FRAME* GetParent();
|
||||
|
||||
bool IsSchematicModified() { return m_isModified; }
|
||||
|
||||
private:
|
||||
SCH_EDIT_FRAME* m_parent;
|
||||
bool m_isModified; // set to true if the schematic is modified
|
||||
std::vector<int> m_OrphansRowIndexes; // list of rows containing orphan lib_id
|
||||
|
||||
|
@ -380,7 +383,6 @@ private:
|
|||
DIALOG_EDIT_COMPONENTS_LIBID::DIALOG_EDIT_COMPONENTS_LIBID( SCH_EDIT_FRAME* aParent )
|
||||
:DIALOG_EDIT_COMPONENTS_LIBID_BASE( aParent )
|
||||
{
|
||||
m_parent = aParent;
|
||||
m_autoWrapRenderer = new GRIDCELL_AUTOWRAP_STRINGRENDERER;
|
||||
|
||||
m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
|
||||
|
@ -494,6 +496,12 @@ void DIALOG_EDIT_COMPONENTS_LIBID::initDlg()
|
|||
}
|
||||
|
||||
|
||||
SCH_EDIT_FRAME* DIALOG_EDIT_COMPONENTS_LIBID::GetParent()
|
||||
{
|
||||
return dynamic_cast<SCH_EDIT_FRAME*>( wxDialog::GetParent() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_EDIT_COMPONENTS_LIBID::AddRowToGrid( bool aMarkRow, const wxString& aReferences,
|
||||
const wxString& aStrLibId )
|
||||
{
|
||||
|
@ -574,7 +582,7 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::validateLibIds()
|
|||
void DIALOG_EDIT_COMPONENTS_LIBID::onApplyButton( wxCommandEvent& event )
|
||||
{
|
||||
if( TransferDataFromWindow() )
|
||||
m_parent->GetCanvas()->Refresh();
|
||||
GetParent()->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
@ -713,7 +721,7 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::setLibIdByBrowser( int aRow )
|
|||
aPreselectedLibid.Parse( current, LIB_ID::ID_SCH, true );
|
||||
|
||||
COMPONENT_SELECTION sel =
|
||||
m_parent->SelectComponentFromLibBrowser( this, NULL, aPreselectedLibid, 0, 0 );
|
||||
GetParent()->SelectComponentFromLibBrowser( this, NULL, aPreselectedLibid, 0, 0 );
|
||||
#endif
|
||||
|
||||
if( sel.LibId.empty() ) // command aborted
|
||||
|
@ -758,6 +766,29 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow()
|
|||
if( cmp.m_Row != row )
|
||||
continue;
|
||||
|
||||
LIB_PART* symbol = nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
symbol = Prj().SchSymbolLibTable()->LoadSymbol( id );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
wxString msg;
|
||||
|
||||
msg.Printf( _( "Error occurred loading symbol %s from library %s."
|
||||
"\n\n%s" ),
|
||||
id.GetLibItemName().wx_str(),
|
||||
id.GetLibNickname().wx_str(),
|
||||
ioe.What() );
|
||||
|
||||
DisplayError( this, msg );
|
||||
}
|
||||
|
||||
if( symbol == nullptr )
|
||||
continue;
|
||||
|
||||
cmp.m_Screen->Remove( cmp.m_Component );
|
||||
SCH_FIELD* value = cmp.m_Component->GetField( VALUE );
|
||||
|
||||
// If value is a proxy for the itemName then make sure it gets updated
|
||||
|
@ -765,7 +796,9 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow()
|
|||
value->SetText( id.GetLibItemName().wx_str() );
|
||||
|
||||
cmp.m_Component->SetLibId( id );
|
||||
cmp.m_Component->SetLibSymbol( symbol->Flatten().release() );
|
||||
change = true;
|
||||
cmp.m_Screen->Append( cmp.m_Component );
|
||||
cmp.m_Screen->SetModify();
|
||||
}
|
||||
}
|
||||
|
@ -773,8 +806,6 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::TransferDataFromWindow()
|
|||
if( change )
|
||||
{
|
||||
m_isModified = true;
|
||||
SCH_SCREENS schematic;
|
||||
schematic.UpdateSymbolLinks();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -798,18 +829,41 @@ void DIALOG_EDIT_COMPONENTS_LIBID::revertChanges()
|
|||
|
||||
if( cmp.m_Component->GetLibId() != id )
|
||||
{
|
||||
LIB_PART* symbol = nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
symbol = Prj().SchSymbolLibTable()->LoadSymbol( id );
|
||||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
// It's probably a bad idea to show a user error dialog here because the
|
||||
// the reason to use this dialog is when there are a bunch of broken library
|
||||
// symbol links so just show a debug trace message for development purposes.
|
||||
wxLogTrace( traceSymbolResolver,
|
||||
"Error occurred loading symbol %s from library %s."
|
||||
"\n\n%s",
|
||||
id.GetLibItemName().wx_str(),
|
||||
id.GetLibNickname().wx_str(),
|
||||
ioe.What() );
|
||||
}
|
||||
|
||||
cmp.m_Screen->Remove( cmp.m_Component );
|
||||
|
||||
if( symbol )
|
||||
cmp.m_Component->SetLibSymbol( symbol->Flatten().release() );
|
||||
else
|
||||
cmp.m_Component->SetLibSymbol( symbol );
|
||||
|
||||
cmp.m_Component->SetLibId( id );
|
||||
cmp.m_Screen->Append( cmp.m_Component );
|
||||
change = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( change )
|
||||
{
|
||||
SCH_SCREENS schematic;
|
||||
schematic.UpdateSymbolLinks();
|
||||
m_parent->GetCanvas()->Refresh();
|
||||
}
|
||||
GetParent()->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -756,9 +756,6 @@ void SCH_SCREEN::Print( RENDER_SETTINGS* aSettings )
|
|||
std::vector<SCH_ITEM*> bitmaps;
|
||||
std::vector<SCH_ITEM*> other;
|
||||
|
||||
// Ensure links are up to date, even if a library was reloaded for some reason:
|
||||
UpdateSymbolLinks();
|
||||
|
||||
for( auto item : Items() )
|
||||
{
|
||||
if( item->IsMoving() || item->IsResized() )
|
||||
|
@ -800,9 +797,6 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter )
|
|||
std::vector< SCH_ITEM* > bitmaps;
|
||||
std::vector< SCH_ITEM* > other;
|
||||
|
||||
// Ensure links are up to date, even if a library was reloaded for some reason:
|
||||
UpdateSymbolLinks();
|
||||
|
||||
for( auto item : Items() )
|
||||
{
|
||||
if( item->IsMoving() || item->IsResized() )
|
||||
|
|
Loading…
Reference in New Issue