Remove bogus assert. Also fix const leak.

Fixes https://gitlab.com/kicad/code/kicad/issues/4367
This commit is contained in:
Jeff Young 2020-05-08 20:22:59 +01:00
parent 3c3984a6fc
commit ae102c7411
2 changed files with 14 additions and 10 deletions

View File

@ -566,19 +566,21 @@ void SCH_COMPONENT::SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSel
}
SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx )
{
const SCH_FIELD* field;
if( (unsigned) aFieldNdx < m_Fields.size() )
field = &m_Fields[aFieldNdx];
else
field = NULL;
return &m_Fields[aFieldNdx];
wxASSERT_MSG( field, wxString::Format( "No field ID %d found in symbol %s.",
aFieldNdx, m_Uuid.AsString() ) );
return nullptr;
}
return const_cast<SCH_FIELD*>( field );
const SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const
{
if( (unsigned) aFieldNdx < m_Fields.size() )
return &m_Fields[aFieldNdx];
return nullptr;
}

View File

@ -389,7 +389,9 @@ public:
*
* @return is the field at \a aFieldNdx or NULL if the field does not exist.
*/
SCH_FIELD* GetField( int aFieldNdx ) const;
SCH_FIELD* GetField( int aFieldNdx );
const SCH_FIELD* GetField( int aFieldNdx ) const;
/**
* Search for a field named \a aFieldName and returns text associated with this field.