PANEL_FP_PROPERTIES_3D_MODEL: fix an issue when trying to edit a filename (MSW specific).
On Windows, FILENAME_RESOLVER::ValidateFileName() always returned a illegal filename test, because the separators ('/' and '\') are in list of illegal chars in filenames on MSW.
This commit is contained in:
parent
4779850c10
commit
b931883876
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2020 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2015-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -1013,7 +1014,17 @@ bool FILENAME_RESOLVER::ValidateFileName( const wxString& aFileName, bool& hasAl
|
|||
|
||||
}
|
||||
|
||||
if( wxString::npos != lpath.find_first_of( wxFileName::GetForbiddenChars() ) )
|
||||
// Test for forbidden chars in filenames. Should be wxFileName::GetForbiddenChars()
|
||||
// On MSW, the list returned by wxFileName::GetForbiddenChars() contains separators
|
||||
// '\'and '/' used here because lpath is a full path (after last ':').
|
||||
// So remove separators
|
||||
wxString lpath_no_sep = lpath;
|
||||
#ifdef __WINDOWS__
|
||||
lpath_no_sep.Replace( "/", " " );
|
||||
lpath_no_sep.Replace( "\\", " " );
|
||||
#endif
|
||||
|
||||
if( wxString::npos != lpath_no_sep.find_first_of( wxFileName::GetForbiddenChars() ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -218,7 +218,11 @@ void PANEL_FP_PROPERTIES_3D_MODEL::On3DModelCellChanged( wxGridEvent& aEvent )
|
|||
|
||||
// The user is warned about failed validation through the updateValidateStatus call below
|
||||
if( filename.empty() || !res->ValidateFileName( filename, hasAlias ) )
|
||||
{
|
||||
wxMessageBox( _( "Error: illegal or empty filename." ) );
|
||||
aEvent.Veto();
|
||||
return;
|
||||
}
|
||||
|
||||
// if the user has specified an alias in the name then prepend ':'
|
||||
if( hasAlias )
|
||||
|
|
Loading…
Reference in New Issue