From df5c5c23ca86ce9c5589e38cd2f40264a883b2e2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 8 Jun 2019 17:32:49 +0200 Subject: [PATCH] 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. --- eeschema/dialogs/dialog_edit_label.cpp | 6 +++++- eeschema/edit_label.cpp | 15 +++++++++------ eeschema/sch_edit_frame.h | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index c2d199998e..594f7007dc 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -309,7 +309,11 @@ bool DIALOG_LABEL_EDITOR::TransferDataFromWindow() m_Parent->GetCanvas()->Refresh(); - text = EscapeString( m_activeTextEntry->GetValue(), CTX_NETNAME ); + // 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 ); if( !text.IsEmpty() ) m_CurrentText->SetText( text ); diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 74ae78f3df..e4a138cd41 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -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(); wxCHECK_RET( aText->CanIncrementLabel(), "Cannot convert text type." ); - if( aText->Type() == aType ) + if( aText->Type() == aNewType ) return; SCH_TEXT* newtext = nullptr; 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 // fix them here. @@ -118,10 +118,13 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType ) txt.Replace( "\r", "_" ); txt.Replace( "\t", "_" ); 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_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; default: - wxASSERT_MSG( false, wxString::Format( "Invalid text type: %d.", aType ) ); + wxASSERT_MSG( false, wxString::Format( "Invalid text type: %d.", aNewType ) ); return; } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 9604196044..f3c0a99c20 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -807,7 +807,7 @@ public: * create a new text, and prepare the undo/redo command data for this change and the * 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