Symbol editor: Inversion sign ("~") incorectly ùmanaged in graphic texts.

It was always replaced with space in a graphic text, but it should happens
only in non quoted texts
Now graphic texts containing ' ' or '~' or '"' are always quoted
(work fine with 4.0 version)

Fixes: lp:1771105
https://bugs.launchpad.net/kicad/+bug/1771105
This commit is contained in:
jean-pierre charras 2018-05-14 17:49:30 +02:00
parent 23a9fcd91d
commit 509793a5b4
1 changed files with 6 additions and 8 deletions

View File

@ -3076,13 +3076,17 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr< LIB_PART >& aPart,
if( *line == '"' )
parseQuotedString( str, aReader, line, &line );
else
{
parseUnquotedString( str, aReader, line, &line );
// In old libs, "spaces" are replaced by '~' in unquoted strings:
str.Replace( "~", " " );
}
if( !str.IsEmpty() )
{
// convert two apostrophes back to double quote
str.Replace( "''", "\"" );
str.Replace( wxT( "~" ), wxT( " " ) );
}
text->SetText( str );
@ -3916,18 +3920,12 @@ void SCH_LEGACY_PLUGIN_CACHE::saveText( LIB_TEXT* aText,
wxString text = aText->GetText();
if( text.Contains( wxT( "~" ) ) || text.Contains( wxT( "\"" ) ) )
if( text.Contains( wxT( " " ) ) || text.Contains( wxT( "~" ) ) || text.Contains( wxT( "\"" ) ) )
{
// convert double quote to similar-looking two apostrophes
text.Replace( wxT( "\"" ), wxT( "''" ) );
text = wxT( "\"" ) + text + wxT( "\"" );
}
else
{
// Spaces are not allowed in text because it is not double quoted:
// changed to '~'
text.Replace( wxT( " " ), wxT( "~" ) );
}
aFormatter->Print( 0, "T %g %d %d %d %d %d %d %s", aText->GetTextAngle(),
aText->GetTextPos().x, aText->GetTextPos().y,