diff --git a/common/widgets/grid_icon_text_helpers.cpp b/common/widgets/grid_icon_text_helpers.cpp index b1f949e977..8a617d48ed 100644 --- a/common/widgets/grid_icon_text_helpers.cpp +++ b/common/widgets/grid_icon_text_helpers.cpp @@ -53,9 +53,10 @@ void GRID_CELL_ICON_TEXT_RENDERER::Draw( wxGrid& aGrid, wxGridCellAttr& aAttr, w // draw the icon // note that the set of icons might be smaller than the set of labels if the last // label is <...>. - if( m_names.Index( value ) < (int) m_icons.size() ) + auto position = m_names.Index( value ); + if( position < (int) m_icons.size() && position != wxNOT_FOUND ) { - bitmap = KiBitmap( (BITMAP_DEF) m_icons[ m_names.Index( value ) ] ); + bitmap = KiBitmap( (BITMAP_DEF) m_icons[ position ] ); aDC.DrawBitmap( bitmap, rect.GetLeft() + 3, rect.GetTop() + 2, true ); } // still need a bitmap to fetch the width diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 93cad792b1..5e59d2ef32 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -180,13 +180,18 @@ public: pin->SetName( aValue ); break; case COL_TYPE: - pin->SetType( (ELECTRICAL_PINTYPE) g_typeNames.Index( aValue ), false ); + if( g_typeNames.Index( aValue ) != wxNOT_FOUND ) + pin->SetType( (ELECTRICAL_PINTYPE) g_typeNames.Index( aValue ), false ); + break; case COL_SHAPE: - pin->SetShape( (GRAPHIC_PINSHAPE) g_shapeNames.Index( aValue ) ); + if( g_shapeNames.Index( aValue ) != wxNOT_FOUND ) + pin->SetShape( (GRAPHIC_PINSHAPE) g_shapeNames.Index( aValue ) ); + break; case COL_ORIENTATION: - pin->SetOrientation( LIB_PIN::GetOrientationCode( + if( g_orientationNames.Index( aValue ) != wxNOT_FOUND ) + pin->SetOrientation( LIB_PIN::GetOrientationCode( g_orientationNames.Index( aValue ) ), false ); break; case COL_NUMBER_SIZE: