Fix file browser text button default path handling.

This commit is contained in:
Wayne Stambaugh 2021-05-27 14:19:06 -04:00
parent b1572dd56b
commit 19607f1488
1 changed files with 10 additions and 10 deletions

View File

@ -75,7 +75,7 @@ void GRID_CELL_TEXT_BUTTON::StartingKey( wxKeyEvent& event )
// Do it ourselves instead. We know that if we get this far that we have // Do it ourselves instead. We know that if we get this far that we have
// a valid character, so not a whole lot of testing needs to be done. // a valid character, so not a whole lot of testing needs to be done.
// wxComboCtrl inherits from wxTextEntry, so can staticly cast // wxComboCtrl inherits from wxTextEntry, so can statically cast
wxTextEntry* textEntry = static_cast<wxTextEntry*>( Combo() ); wxTextEntry* textEntry = static_cast<wxTextEntry*>( Combo() );
int ch; int ch;
@ -356,18 +356,17 @@ protected:
void OnButtonClick() override void OnButtonClick() override
{ {
wxString path = GetValue(); wxFileName fn = GetValue();
if( path.IsEmpty() ) if( fn.GetPath().IsEmpty() && m_currentDir )
path = *m_currentDir; fn.SetPath( *m_currentDir );
else else
path = ExpandEnvVarSubstitutions( path, &m_dlg->Prj() ); fn.SetPath( ExpandEnvVarSubstitutions( fn.GetPath(), &m_dlg->Prj() ) );
if( m_ext ) if( m_ext )
{ {
wxFileName fn( path ); wxFileDialog dlg( m_dlg, _( "Select a File" ), fn.GetPath(), fn.GetFullName(), *m_ext,
wxFileDialog dlg( nullptr, _( "Select a File" ), fn.GetPath(), fn.GetFullName(), *m_ext, wxFD_FILE_MUST_EXIST | wxFD_OPEN );
wxFD_FILE_MUST_EXIST | wxFD_OPEN );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
{ {
@ -391,12 +390,13 @@ protected:
if( !m_grid->CommitPendingChanges() ) if( !m_grid->CommitPendingChanges() )
{;} // shouldn't happen, but Coverity doesn't know that {;} // shouldn't happen, but Coverity doesn't know that
*m_currentDir = lastPath; if( m_currentDir )
*m_currentDir = lastPath;
} }
} }
else else
{ {
wxDirDialog dlg( nullptr, _( "Select Path" ), path, wxDirDialog dlg( m_dlg, _( "Select Path" ), fn.GetPath(),
wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST ); wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )