Eeschema: fix value and footprint field update bug.

Don't assume all identical references should have the same value.
Filter by checking that only symbol units having the same reference
also have the same library identifier before updating the value and
footprint fields.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/8313
This commit is contained in:
Wayne Stambaugh 2021-05-06 07:13:08 -04:00
parent fe5c2d30a3
commit 68085820ff
4 changed files with 37 additions and 29 deletions

View File

@ -323,7 +323,8 @@ DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent,
m_isPower = true;
}
m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED, &DIALOG_SCH_EDIT_ONE_FIELD::onScintillaCharAdded, this );
m_StyledTextCtrl->Bind( wxEVT_STC_CHARADDED,
&DIALOG_SCH_EDIT_ONE_FIELD::onScintillaCharAdded, this );
init();
}
@ -469,6 +470,7 @@ void DIALOG_SCH_EDIT_ONE_FIELD::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH*
{
wxString ref = symbol->GetRef( aSheetPath );
int unit = symbol->GetUnit();
LIB_ID libId = symbol->GetLibId();
for( SCH_SHEET_PATH& sheet : editFrame->Schematic().GetSheets() )
{
@ -476,7 +478,7 @@ void DIALOG_SCH_EDIT_ONE_FIELD::UpdateField( SCH_FIELD* aField, SCH_SHEET_PATH*
std::vector<SCH_COMPONENT*> otherUnits;
constexpr bool appendUndo = true;
CollectOtherUnits( ref, unit, sheet, &otherUnits );
CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
for( SCH_COMPONENT* otherUnit : otherUnits )
{

View File

@ -118,11 +118,13 @@ public:
}
m_typeAttr = new wxGridCellAttr;
m_typeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinTypeIcons(), PinTypeNames() ) );
m_typeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinTypeIcons(),
PinTypeNames() ) );
m_typeAttr->SetReadOnly( true );
m_shapeAttr = new wxGridCellAttr;
m_shapeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinShapeIcons(), PinShapeNames() ) );
m_shapeAttr->SetRenderer( new GRID_CELL_ICON_TEXT_RENDERER( PinShapeIcons(),
PinShapeNames() ) );
m_shapeAttr->SetReadOnly( true );
}
@ -638,7 +640,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
switch( m_mirrorCtrl->GetSelection() )
{
case 0: break;
case 0: break;
case 1: m_comp->SetOrientation( CMP_MIRROR_X ); break;
case 2: m_comp->SetOrientation( CMP_MIRROR_Y ); break;
}
@ -709,6 +711,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
{
wxString ref = m_comp->GetRef( &GetParent()->GetCurrentSheet() );
int unit = m_comp->GetUnit();
LIB_ID libId = m_comp->GetLibId();
for( SCH_SHEET_PATH& sheet : GetParent()->Schematic().GetSheets() )
{
@ -716,7 +719,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
std::vector<SCH_COMPONENT*> otherUnits;
constexpr bool appendUndo = true;
CollectOtherUnits( ref, unit, sheet, &otherUnits );
CollectOtherUnits( ref, unit, libId, sheet, &otherUnits );
for( SCH_COMPONENT* otherUnit : otherUnits )
{
@ -872,7 +875,8 @@ void DIALOG_SYMBOL_PROPERTIES::OnMoveUp( wxCommandEvent& event )
m_fieldsGrid->ForceRefresh();
m_fieldsGrid->SetGridCursor( i - 1, m_fieldsGrid->GetGridCursorCol() );
m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(), m_fieldsGrid->GetGridCursorCol() );
m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
m_fieldsGrid->GetGridCursorCol() );
}
else
{
@ -896,7 +900,8 @@ void DIALOG_SYMBOL_PROPERTIES::OnMoveDown( wxCommandEvent& event )
m_fieldsGrid->ForceRefresh();
m_fieldsGrid->SetGridCursor( i + 1, m_fieldsGrid->GetGridCursorCol() );
m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(), m_fieldsGrid->GetGridCursorCol() );
m_fieldsGrid->MakeCellVisible( m_fieldsGrid->GetGridCursorRow(),
m_fieldsGrid->GetGridCursorCol() );
}
else
{

View File

@ -231,8 +231,8 @@ bool EE_COLLECTOR::IsCorner() const
}
void CollectOtherUnits( const wxString& aRef, int aUnit, SCH_SHEET_PATH& aSheet,
std::vector<SCH_COMPONENT*>* otherUnits )
void CollectOtherUnits( const wxString& aRef, int aUnit, const LIB_ID& aLibId,
SCH_SHEET_PATH& aSheet, std::vector<SCH_COMPONENT*>* otherUnits )
{
SCH_REFERENCE_LIST symbols;
aSheet.GetSymbols( symbols );
@ -241,7 +241,8 @@ void CollectOtherUnits( const wxString& aRef, int aUnit, SCH_SHEET_PATH& aSheet,
{
SCH_REFERENCE symbol = symbols[i];
if( symbol.GetRef() == aRef && symbol.GetUnit() != aUnit )
if( symbol.GetRef() == aRef && symbol.GetSymbol()->GetLibId() == aLibId
&& symbol.GetUnit() != aUnit )
otherUnits->push_back( symbol.GetSymbol() );
}
}

View File

@ -74,36 +74,36 @@ public:
SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
/**
* Function Collect
* scans a EDA_ITEM using this class's Inspector method, which does the collection.
* Scan a #EDA_ITEM using this class's Inspector method which does the collection.
*
* @param aScreen The eeschema screen to use for scanning
* @param aFilterList A list of #KICAD_T types with a terminating #EOT, that determines
* what is to be collected and the priority order of the resulting
* collection.
* @param aPos A wxPoint to use in hit-testing.
* @param aUnit A symbol unit filter (for symbol editor)
* @param aConvert A DeMorgan filter (for symbol editor)
* @param aPos are the coordinates to use in hit testing.
* @param aUnit is the symbol unit filter (for symbol editor).
* @param aConvert is the DeMorgan filter (for symbol editor)
*/
void Collect( SCH_SCREEN* aScreen, const KICAD_T aFilterList[], const wxPoint& aPos,
int aUnit = 0, int aConvert = 0 );
int aUnit = 0, int aConvert = 0 );
/**
* Function Collect
* scans a EDA_ITEM using this class's Inspector method, which does the collection.
* @param aItems The LIB_PART multivector holding the part components
* @param aFilterList A list of #KICAD_T types with a terminating #EOT, that determines
* Scan an #EDA_ITEM using this class's Inspector method which does the collection.
*
* @param aItems is a LIB_PART multivector holding the part items.
* @param aFilterList is a list of #KICAD_T types with a terminating #EOT, that determines
* what is to be collected and the priority order of the resulting
* collection.
* @param aPos A wxPoint to use in hit-testing.
* @param aUnit A symbol unit filter (for symbol editor)
* @param aConvert A DeMorgan filter (for symbol editor)
* @param aPos are the coordinates to use in hit testing.
* @param aUnit is the symbol unit filter (for symbol editor).
* @param aConvert is the DeMorgan filter (for symbol editor).
*/
void Collect( LIB_ITEMS_CONTAINER& aItems, const KICAD_T aFilterList[], const wxPoint& aPos,
int aUnit = 0, int aConvert = 0 );
int aUnit = 0, int aConvert = 0 );
/**
* Function IsCorner
* tests if the collected items forms as corner of two line segments.
* Test if the collected items form a corner of two line segments.
*
* @return True if the collected items form a corner of two line segments.
*/
bool IsCorner() const;
@ -114,7 +114,7 @@ public:
};
void CollectOtherUnits( const wxString& thisRef, int thisUnit, SCH_SHEET_PATH& aSheet,
std::vector<SCH_COMPONENT*>* otherUnits );
void CollectOtherUnits( const wxString& thisRef, int thisUnit, const LIB_ID& aLibId,
SCH_SHEET_PATH& aSheet, std::vector<SCH_COMPONENT*>* otherUnits );
#endif // EE_COLLECTORS_H