Don't try accessing library table rows that don't exist
When exiting the dialog without actually visiting the table, the grid cursor could be missing, so it could return -1. Guard against that condition. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16342
This commit is contained in:
parent
11be5d6f1d
commit
53fd1aaf5e
|
@ -503,9 +503,18 @@ void GRID_CELL_PATH_EDITOR::Create( wxWindow* aParent, wxWindowID aId,
|
|||
void GRID_CELL_PATH_EDITOR::UpdateFilterString( const wxString& aFilterString )
|
||||
{
|
||||
if( m_fileFilterFn )
|
||||
m_fileFilter = m_fileFilterFn( m_grid, m_grid->GetGridCursorRow() );
|
||||
{
|
||||
int row = m_grid->GetGridCursorRow();
|
||||
|
||||
// When closing the window, the cursor position could be negative if no rows were selected,
|
||||
// so don't try to update a filter for a non-existent row
|
||||
if( row >= 0 )
|
||||
m_fileFilter = m_fileFilterFn( m_grid, row );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fileFilter = aFilterString;
|
||||
}
|
||||
|
||||
// Ensure that the control switches between files and directories properly
|
||||
TEXT_BUTTON_FILE_BROWSER* button = dynamic_cast<TEXT_BUTTON_FILE_BROWSER*>( m_control );
|
||||
|
|
Loading…
Reference in New Issue