Fix segfaults from not checking index
Return value of wxArrayString.Index() always needs to be check for existence.
This commit is contained in:
parent
8b5127d9bc
commit
c3a295df1a
|
@ -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
|
||||
|
|
|
@ -180,12 +180,17 @@ public:
|
|||
pin->SetName( aValue );
|
||||
break;
|
||||
case COL_TYPE:
|
||||
if( g_typeNames.Index( aValue ) != wxNOT_FOUND )
|
||||
pin->SetType( (ELECTRICAL_PINTYPE) g_typeNames.Index( aValue ), false );
|
||||
|
||||
break;
|
||||
case COL_SHAPE:
|
||||
if( g_shapeNames.Index( aValue ) != wxNOT_FOUND )
|
||||
pin->SetShape( (GRAPHIC_PINSHAPE) g_shapeNames.Index( aValue ) );
|
||||
|
||||
break;
|
||||
case COL_ORIENTATION:
|
||||
if( g_orientationNames.Index( aValue ) != wxNOT_FOUND )
|
||||
pin->SetOrientation( LIB_PIN::GetOrientationCode(
|
||||
g_orientationNames.Index( aValue ) ), false );
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue