Fix incorrect behavior of ReplaceIllegalFileNameChars( wxString& aName, int aReplaceChar ) for non ASCII8 chars.

(this function was using a comparison using chars to test wide chars)

Fixes: lp:1764055
https://bugs.launchpad.net/kicad/+bug/1764055
This commit is contained in:
jean-pierre charras 2018-04-15 10:06:53 +02:00
parent 9203e397fe
commit 3e64c9de38
2 changed files with 3 additions and 1 deletions

View File

@ -515,10 +515,11 @@ bool ReplaceIllegalFileNameChars( wxString& aName, int aReplaceChar )
bool changed = false; bool changed = false;
wxString result; wxString result;
result.reserve( aName.Length() ); result.reserve( aName.Length() );
wxString illWChars = GetIllegalFileNameWxChars();
for( wxString::iterator it = aName.begin(); it != aName.end(); ++it ) for( wxString::iterator it = aName.begin(); it != aName.end(); ++it )
{ {
if( strchr( illegalFileNameChars, *it ) ) if( illWChars.Find( *it ) != wxNOT_FOUND )
{ {
if( aReplaceChar ) if( aReplaceChar )
result += aReplaceChar; result += aReplaceChar;

View File

@ -296,6 +296,7 @@ void LIB_EDIT_FRAME::OnCreateNewPart( wxCommandEvent& event )
} }
wxString name = dlg.GetName(); wxString name = dlg.GetName();
// Currently, symbol names cannot include a space, that breaks libraries:
name.Replace( " ", "_" ); name.Replace( " ", "_" );
// Test if there is a component with this name already. // Test if there is a component with this name already.