From ae102c74117b66c4b083fdd1bb5a66ef1a44f154 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 8 May 2020 20:22:59 +0100 Subject: [PATCH] Remove bogus assert. Also fix const leak. Fixes https://gitlab.com/kicad/code/kicad/issues/4367 --- eeschema/sch_component.cpp | 20 +++++++++++--------- eeschema/sch_component.h | 4 +++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index ce23c7e84a..61ff7de27b 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -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( field ); + +const SCH_FIELD* SCH_COMPONENT::GetField( int aFieldNdx ) const +{ + if( (unsigned) aFieldNdx < m_Fields.size() ) + return &m_Fields[aFieldNdx]; + + return nullptr; } diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 90df618783..a576763588 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -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.