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
|
// draw the icon
|
||||||
// note that the set of icons might be smaller than the set of labels if the last
|
// note that the set of icons might be smaller than the set of labels if the last
|
||||||
// label is <...>.
|
// 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 );
|
aDC.DrawBitmap( bitmap, rect.GetLeft() + 3, rect.GetTop() + 2, true );
|
||||||
}
|
}
|
||||||
// still need a bitmap to fetch the width
|
// still need a bitmap to fetch the width
|
||||||
|
|
|
@ -180,13 +180,18 @@ public:
|
||||||
pin->SetName( aValue );
|
pin->SetName( aValue );
|
||||||
break;
|
break;
|
||||||
case COL_TYPE:
|
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;
|
break;
|
||||||
case COL_SHAPE:
|
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;
|
break;
|
||||||
case COL_ORIENTATION:
|
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 );
|
g_orientationNames.Index( aValue ) ), false );
|
||||||
break;
|
break;
|
||||||
case COL_NUMBER_SIZE:
|
case COL_NUMBER_SIZE:
|
||||||
|
|
Loading…
Reference in New Issue