Don't update file browser filter if control doesn't exist

When the grid is being validated, SetValue is called, which then ends up
running the file filter update. However, if the cell was never selected,
the file browser button would never have been created.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16316
This commit is contained in:
Ian McInerney 2023-12-08 22:09:55 +00:00
parent 0db362a907
commit d8bb9b1e66
1 changed files with 4 additions and 4 deletions

View File

@ -508,8 +508,8 @@ void GRID_CELL_PATH_EDITOR::UpdateFilterString( const wxString& aFilterString )
m_fileFilter = aFilterString;
// Ensure that the control switches between files and directories properly
if( m_fileFilter.IsEmpty() )
static_cast<TEXT_BUTTON_FILE_BROWSER*>( m_control )->UpdateFileFilter( nullptr );
else
static_cast<TEXT_BUTTON_FILE_BROWSER*>( m_control )->UpdateFileFilter( &m_fileFilter );
TEXT_BUTTON_FILE_BROWSER* button = dynamic_cast<TEXT_BUTTON_FILE_BROWSER*>( m_control );
if( button )
button->UpdateFileFilter( m_fileFilter.IsEmpty() ? nullptr : &m_fileFilter );
}