Eeschema: replace invalid characters when converting from text to label.

Fixes lp:1829664

https://bugs.launchpad.net/kicad/+bug/1829664
(cherry picked from commit 0403437ad0)
This commit is contained in:
Wayne Stambaugh 2019-05-20 14:43:47 -04:00
parent 62a5302bc4
commit 691f05273e
2 changed files with 17 additions and 6 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2019 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
@ -98,10 +98,6 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( int aType )
}
/*
* ConvertTextType changes a text from one type to another. It creates a new text of the
* appropriate type and deletes the old one.
*/
void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType )
{
bool selected = aText->IsSelected();
@ -113,7 +109,18 @@ void SCH_EDIT_FRAME::ConvertTextType( SCH_TEXT* aText, KICAD_T aType )
SCH_TEXT* newtext = nullptr;
const wxPoint& position = aText->GetPosition();
const wxString txt = aText->GetText();
wxString txt = aText->GetText();
// There can be characters in a SCH_TEXT object that can break labels so we have to
// fix them here.
if( aText->Type() == SCH_TEXT_T )
{
txt.Replace( "\n", "_" );
txt.Replace( "\r", "_" );
txt.Replace( "\t", "_" );
txt.Replace( " ", "_" );
txt.Replace( "/", "_" );
}
switch( aType )
{

View File

@ -834,6 +834,10 @@ public:
*
* The new text, label, hierarchical label, or global label is created from the old text
* and the old text object is deleted.
*
* A tricky case is when the 'old" text is being edited (i.e. moving) because we must
* 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 );