Eeschema: fix incorrect handling of '/' in graphic texts.

It was escaped (replaced by "{slash}") in dialog.
This is right for labels, not for texts.
A consequence was the directives in spice simul can be broken.
Now the graphic text is not escaped.
This commit is contained in:
jean-pierre charras 2019-06-08 17:32:49 +02:00
parent 598b140112
commit df5c5c23ca
3 changed files with 15 additions and 8 deletions

View File

@ -309,6 +309,10 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow()
m_Parent->GetCanvas()->Refresh(); m_Parent->GetCanvas()->Refresh();
// Escape string only if is is a label. For a simple graphic text do not change anything
if( m_CurrentText->Type() == SCH_TEXT_T )
text = m_activeTextEntry->GetValue();
else
text = EscapeString( m_activeTextEntry->GetValue(), CTX_NETNAME ); text = EscapeString( m_activeTextEntry->GetValue(), CTX_NETNAME );
if( !text.IsEmpty() ) if( !text.IsEmpty() )

View File

@ -97,18 +97,18 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType )
} }
void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType ) void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aNewType )
{ {
bool selected = aText->IsSelected(); bool selected = aText->IsSelected();
wxCHECK_RET( aText->CanIncrementLabel(), "Cannot convert text type." ); wxCHECK_RET( aText->CanIncrementLabel(), "Cannot convert text type." );
if( aText->Type() == aType ) if( aText->Type() == aNewType )
return; return;
SCH_TEXT* newtext = nullptr; SCH_TEXT* newtext = nullptr;
const wxPoint& position = aText->GetPosition(); const wxPoint& position = aText->GetPosition();
wxString txt = aText->GetText(); wxString txt = UnescapeString( aText->GetText() );
// There can be characters in a SCH_TEXT object that can break labels so we have to // There can be characters in a SCH_TEXT object that can break labels so we have to
// fix them here. // fix them here.
@ -118,10 +118,13 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType )
txt.Replace( "\r", "_" ); txt.Replace( "\r", "_" );
txt.Replace( "\t", "_" ); txt.Replace( "\t", "_" );
txt.Replace( " ", "_" ); txt.Replace( " ", "_" );
txt.Replace( "/", "_" );
} }
switch( aType ) // label strings are "escaped" i.e. a '/' is replaced by "{slash}"
if( aNewType != SCH_TEXT_T )
txt = EscapeString( txt, CTX_NETNAME );
switch( aNewType )
{ {
case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break; case SCH_LABEL_T: newtext = new SCH_LABEL( position, txt ); break;
case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break; case SCH_GLOBAL_LABEL_T: newtext = new SCH_GLOBALLABEL( position, txt ); break;
@ -129,7 +132,7 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType )
case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break; case SCH_TEXT_T: newtext = new SCH_TEXT( position, txt ); break;
default: default:
wxASSERT_MSG( false, wxString::Format( "Invalid text type: %d.", aType ) ); wxASSERT_MSG( false, wxString::Format( "Invalid text type: %d.", aNewType ) );
return; return;
} }

View File

@ -807,7 +807,7 @@ public:
* create a new text, and prepare the undo/redo command data for this change and the * create a new text, and prepare the undo/redo command data for this change and the
* current move/edit command * current move/edit command
*/ */
void ConvertTextType( SCH_TEXT* aText, KICAD_T aType ); void ConvertTextType( SCH_TEXT* aText, KICAD_T aNewType );
/** /**
* Launches the "Edit Text/Label" dialog * Launches the "Edit Text/Label" dialog