diff --git a/common/lib_tree_model.cpp b/common/lib_tree_model.cpp index 4bc8f155bd..92dc39a77d 100644 --- a/common/lib_tree_model.cpp +++ b/common/lib_tree_model.cpp @@ -213,7 +213,7 @@ void LIB_TREE_NODE_LIB_ID::UpdateScore( EDA_COMBINED_MATCHER& aMatcher ) if( !m_Normalized ) { - m_MatchName = m_MatchName.Lower(); + m_MatchName = UnescapeString( m_MatchName ).Lower(); m_SearchText = m_SearchText.Lower(); m_Normalized = true; } diff --git a/common/lib_tree_model_adapter.cpp b/common/lib_tree_model_adapter.cpp index 01ef51ecbd..a8f3b4fbcb 100644 --- a/common/lib_tree_model_adapter.cpp +++ b/common/lib_tree_model_adapter.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #define PINNED_ITEMS_KEY wxT( "PinnedItems" ) @@ -455,7 +456,7 @@ void LIB_TREE_MODEL_ADAPTER::GetValue( wxVariant& aVariant, { default: // column == -1 is used for default Compare function case 0: - aVariant = node->m_Name; + aVariant = UnescapeString( node->m_Name ); break; case 1: aVariant = node->m_Desc; diff --git a/common/string.cpp b/common/string.cpp index 9a419978fa..f032f99169 100644 --- a/common/string.cpp +++ b/common/string.cpp @@ -157,6 +157,14 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ) { if( c == '{' ) converted += "{brace}"; + else if( c == '/' ) + converted += "{slash}"; + else if( c == '\\' ) + converted += "{backslash}"; + else if( c == '<' ) + converted += "{lt}"; + else if( c == '>' ) + converted += "{gt}"; else if( c == ':' ) converted += "{colon}"; else if( c == '\n' || c == '\r' ) diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 0a17f6a4e3..ab4f0e9a54 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -606,7 +606,7 @@ bool DIALOG_CHANGE_SYMBOLS::processSymbol( SCH_SYMBOL* aSymbol, const SCH_SHEET_ if( i == REFERENCE_FIELD ) aSymbol->SetRef( aInstance, UTIL::GetRefDesUnannotated( libField->GetText() ) ); else if( i == VALUE_FIELD ) - aSymbol->SetValue( aInstance, libField->GetText() ); + aSymbol->SetValue( aInstance, UnescapeString( libField->GetText() ) ); else if( i == FOOTPRINT_FIELD ) aSymbol->SetFootprint( aInstance, libField->GetText() ); else diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index a43c25f89f..48308cde41 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -282,6 +282,9 @@ DIALOG_LIB_EDIT_ONE_FIELD::DIALOG_LIB_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, { m_fieldId = aField->GetId(); + if( m_fieldId == VALUE_FIELD ) + m_text = UnescapeString( aField->GetText() ); + // When in the library editor, power symbols can be renamed. m_isPower = false; init(); diff --git a/eeschema/dialogs/dialog_edit_one_field.h b/eeschema/dialogs/dialog_edit_one_field.h index 344c1d3896..fd849794f8 100644 --- a/eeschema/dialogs/dialog_edit_one_field.h +++ b/eeschema/dialogs/dialog_edit_one_field.h @@ -117,11 +117,16 @@ public: void UpdateField( LIB_FIELD* aField ) { - aField->SetText( m_text ); + wxString value = m_text; + + if( m_fieldId == VALUE_FIELD ) + value = EscapeString( value, CTX_LIBID ); + + aField->SetText( value ); // VALUE === symbol name, so update the parent symbol if it changes. - if( aField->GetId() == VALUE_FIELD && aField->GetParent() ) - aField->GetParent()->SetName( m_text ); + if( m_fieldId == VALUE_FIELD && aField->GetParent() ) + aField->GetParent()->SetName( value ); updateText( aField ); } diff --git a/eeschema/dialogs/dialog_edit_symbols_libid.cpp b/eeschema/dialogs/dialog_edit_symbols_libid.cpp index 099e09ae7f..ec207afb81 100644 --- a/eeschema/dialogs/dialog_edit_symbols_libid.cpp +++ b/eeschema/dialogs/dialog_edit_symbols_libid.cpp @@ -30,7 +30,6 @@ #include #include -#include #include #include #include @@ -44,6 +43,8 @@ #include #include #include +#include + #define COL_REFS 0 #define COL_CURR_LIBID 1 @@ -696,6 +697,11 @@ bool DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow() if( !validateLibIds() ) return false; + auto getName = []( const LIB_ID& aLibId ) + { + return UnescapeString( aLibId.GetLibItemName().wx_str() ); + }; + int row_max = m_grid->GetNumberRows() - 1; for( int row = 0; row <= row_max; row++ ) @@ -743,8 +749,8 @@ bool DIALOG_EDIT_SYMBOLS_LIBID::TransferDataFromWindow() SCH_FIELD* value = candidate.m_Symbol->GetField( VALUE_FIELD ); // If value is a proxy for the itemName then make sure it gets updated - if( candidate.m_Symbol->GetLibId().GetLibItemName().wx_str() == value->GetText() ) - candidate.m_Symbol->SetValue( id.GetLibItemName().wx_str() ); + if( getName( candidate.m_Symbol->GetLibId() ) == value->GetText() ) + candidate.m_Symbol->SetValue( getName( id ) ); candidate.m_Symbol->SetLibId( id ); candidate.m_Symbol->SetLibSymbol( symbol->Flatten().release() ); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index 027439d306..09f3e6edf5 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #ifdef KICAD_SPICE #include @@ -165,7 +166,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow() m_grid->ProcessTableMessage( msg ); adjustGridColumns( m_grid->GetRect().GetWidth() ); - m_SymbolNameCtrl->ChangeValue( m_libEntry->GetName() ); + m_SymbolNameCtrl->ChangeValue( UnescapeString( m_libEntry->GetName() ) ); m_DescCtrl->ChangeValue( m_libEntry->GetDescription() ); m_KeywordCtrl->ChangeValue( m_libEntry->GetKeyWords() ); @@ -200,7 +201,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow() wxCHECK( rootSymbol, false ); - wxString parentName = rootSymbol->GetName(); + wxString parentName = UnescapeString( rootSymbol->GetName() ); int selection = m_inheritanceSelectCombo->FindString( parentName ); wxCHECK( selection != wxNOT_FOUND, false ); @@ -312,7 +313,8 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() wxString msg; msg.Printf( _( "The name '%s' conflicts with an existing entry in the library '%s'." ), - newName, libName ); + UnescapeString( newName ), + libName ); DisplayErrorMessage( this, msg ); return false; } @@ -339,7 +341,7 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataFromWindow() // Update the parent for inherited symbols if( m_libEntry->IsAlias() ) { - wxString parentName = m_inheritanceSelectCombo->GetValue(); + wxString parentName = EscapeString( m_inheritanceSelectCombo->GetValue(), CTX_LIBID ); // The parentName was verified to be non-empty in the Validator wxString libName = m_Parent->GetCurLib(); @@ -435,7 +437,9 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event ) } } else if( event.GetRow() == VALUE_FIELD && event.GetCol() == FDC_VALUE ) + { m_SymbolNameCtrl->ChangeValue( event.GetString() ); + } editor->DecRef(); } diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index 03fd7668cc..f565ea0eb0 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -781,7 +781,7 @@ void DIALOG_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event ) if( newName.CmpNoCase( m_fieldsGrid->GetCellValue( i, FDC_NAME ) ) == 0 ) { - DisplayError( this, wxString::Format( _( "The name '%s' is already in use." ), + DisplayError( this, wxString::Format( _( "Field name '%s' already in use." ), newName ) ); event.Veto(); m_delayedFocusRow = event.GetRow(); diff --git a/eeschema/dialogs/dialog_update_symbol_fields.cpp b/eeschema/dialogs/dialog_update_symbol_fields.cpp index 9345bcb24b..93a62f04a1 100644 --- a/eeschema/dialogs/dialog_update_symbol_fields.cpp +++ b/eeschema/dialogs/dialog_update_symbol_fields.cpp @@ -25,6 +25,7 @@ #include #include #include +#include bool g_removeExtraLibFields = false; @@ -44,7 +45,7 @@ DIALOG_UPDATE_SYMBOL_FIELDS::DIALOG_UPDATE_SYMBOL_FIELDS( SYMBOL_EDIT_FRAME* aPa wxASSERT( aParent ); wxASSERT( aSymbol ); - m_parentSymbolReadOnly->SetValue( m_symbol->GetParent().lock()->GetName() ); + m_parentSymbolReadOnly->SetValue( UnescapeString( m_symbol->GetParent().lock()->GetName() ) ); for( int i = 0; i < MANDATORY_FIELDS; ++i ) { diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index d8dfb44497..411a20f395 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -503,7 +503,7 @@ void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) { wxString filePath = dlg.GetDirectory() + wxFileName::GetPathSeparator() + file; wxFileName fn( filePath ); - wxString nickname = LIB_ID::FixIllegalChars( fn.GetName() ); + wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), true ); bool doAdd = true; if( cur_model()->ContainsNickname( nickname ) ) diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index d25134de29..0ecbea2f81 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -36,6 +36,7 @@ #include #include "eda_doc.h" #include +#include enum @@ -381,7 +382,7 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) return field.GetName( false ); case FDC_VALUE: - return field.GetText(); + return UnescapeString( field.GetText() ); case FDC_SHOWN: return StringFromBool( field.IsVisible() ); @@ -487,6 +488,10 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue value = fn.GetFullPath(); } } + else if( m_parentType == SCH_SYMBOL_T && aRow == VALUE_FIELD ) + { + value = EscapeString( value, CTX_LIBID ); + } field.SetText( value ); } diff --git a/eeschema/generate_alias_info.cpp b/eeschema/generate_alias_info.cpp index 5d47991ca6..8cfdca568f 100644 --- a/eeschema/generate_alias_info.cpp +++ b/eeschema/generate_alias_info.cpp @@ -106,7 +106,7 @@ public: protected: void SetHtmlName() { - m_html.Replace( "__NAME__", EscapeHTML( m_symbol->GetName() ) ); + m_html.Replace( "__NAME__", EscapeHTML( UnescapeString( m_symbol->GetName() ) ) ); } @@ -130,7 +130,7 @@ protected: } m_html.Replace( "__ALIASOF__", wxString::Format( AliasOfFormat, - EscapeHTML( root_name ), + EscapeHTML( UnescapeString( root_name ) ), EscapeHTML( root_desc ) ) ); } } diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 199f0f51ef..999fc916df 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -313,12 +313,10 @@ wxString LIB_SYMBOL::GetUnitReference( int aUnit ) void LIB_SYMBOL::SetName( const wxString& aName ) { - wxString validatedName = LIB_ID::FixIllegalChars( aName ); + m_name = aName; + m_libId.SetLibItemName( aName, false ); - m_name = validatedName; - m_libId.SetLibItemName( validatedName, false ); - - GetValueField().SetText( validatedName ); + GetValueField().SetText( aName ); } diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index ebd090c328..31d556f84f 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -89,7 +89,7 @@ static void getSymbols( SCHEMATIC* aSchematic, std::vector& aSymbol static LIB_SYMBOL* findSymbol( const wxString& aName, SYMBOL_LIBS* aLibs, bool aCached ) { LIB_SYMBOL *symbol = NULL; - wxString new_name = LIB_ID::FixIllegalChars( aName ); + wxString new_name = LIB_ID::FixIllegalChars( aName, false ); for( SYMBOL_LIB& each_lib : *aLibs ) { @@ -150,7 +150,7 @@ void RESCUE_CASE_CANDIDATE::FindRescues( RESCUER& aRescuer, for( SCH_SYMBOL* eachSymbol : *( aRescuer.GetSymbols() ) ) { symbol_name = eachSymbol->GetLibId().GetLibItemName(); - search_name = LIB_ID::FixIllegalChars( symbol_name ); + search_name = LIB_ID::FixIllegalChars( symbol_name, false ); if( last_symbol_name != symbol_name ) { @@ -255,7 +255,7 @@ void RESCUE_CACHE_CANDIDATE::FindRescues( RESCUER& aRescuer, for( SCH_SYMBOL* eachSymbol : *( aRescuer.GetSymbols() ) ) { symbol_name = eachSymbol->GetLibId().GetLibItemName(); - search_name = LIB_ID::FixIllegalChars( symbol_name ); + search_name = LIB_ID::FixIllegalChars( symbol_name, false ); if( old_symbol_name != symbol_name ) { @@ -426,7 +426,7 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( } // Fix illegal LIB_ID name characters. - wxString new_name = LIB_ID::FixIllegalChars( symbol_id.GetLibItemName() ); + wxString new_name = LIB_ID::FixIllegalChars( symbol_id.GetLibItemName(), false ); // Differentiate symbol name in the rescue library by appending the symbol library // table nickname to the symbol name to prevent name clashes in the rescue library. diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index dbdf6bcac9..9d3f4455fd 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include "sch_painter.h" namespace KIGFX @@ -672,7 +673,7 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer ) double orient = aField->GetTextAngleRadians(); - strokeText( aField->GetText(), pos, orient ); + strokeText( UnescapeString( aField->GetText() ), pos, orient ); } // Draw the umbilical line diff --git a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp index f6b8505ae7..1faf020950 100644 --- a/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp +++ b/eeschema/sch_plugins/cadstar/cadstar_sch_archive_loader.cpp @@ -535,7 +535,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances() // Name of the net that the symbol instance in CADSTAR refers to: wxString symbolInstanceNetName = sym.SymbolVariant.Reference; - symbolInstanceNetName = LIB_ID::FixIllegalChars( symbolInstanceNetName ); + symbolInstanceNetName = EscapeString( symbolInstanceNetName, CTX_LIBID ); // Name of the symbol we will use for saving the part in KiCad // Note: In CADSTAR all power symbols will start have the reference name be diff --git a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp index 2b743692e0..f69facd7ad 100644 --- a/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp +++ b/eeschema/sch_plugins/eagle/sch_eagle_plugin.cpp @@ -3006,7 +3006,7 @@ void SCH_EAGLE_PLUGIN::addImplicitConnections( SCH_SYMBOL* aSymbol, SCH_SCREEN* wxString SCH_EAGLE_PLUGIN::fixSymbolName( const wxString& aName ) { - wxString ret = LIB_ID::FixIllegalChars( aName ); + wxString ret = EscapeString( aName, CTX_LIBID ); return ret; } diff --git a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp index 1a0e2b39cc..d226376a7e 100644 --- a/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp +++ b/eeschema/sch_plugins/legacy/sch_legacy_plugin.cpp @@ -2734,7 +2734,7 @@ void SCH_LEGACY_PLUGIN_CACHE::loadDocs() aliasName = wxString::FromUTF8( line ); aliasName.Trim(); - aliasName = LIB_ID::FixIllegalChars( aliasName ); + aliasName = EscapeString( aliasName, CTX_LIBID ); LIB_SYMBOL_MAP::iterator it = m_symbols.find( aliasName ); diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index d5f452e607..b5464490de 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -36,6 +36,7 @@ #include #include #include +#include /** * Convert a wxString to UTF8 and replace any control characters with a ~, @@ -791,9 +792,9 @@ void SCH_SYMBOL::UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, b else if( id == VALUE_FIELD ) { if( aResetOtherFields ) - SetValue( m_lib_id.GetLibItemName() ); // fetch alias-specific value + SetValue( UnescapeString( m_lib_id.GetLibItemName() ) ); // alias-specific value else - SetValue( libField->GetText() ); + SetValue( UnescapeString( libField->GetText() ) ); } else if( id == FOOTPRINT_FIELD ) { @@ -803,7 +804,7 @@ void SCH_SYMBOL::UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, b else if( id == DATASHEET_FIELD ) { if( aResetOtherFields ) - schField->SetText( GetDatasheet() ); // fetch alias-specific value + schField->SetText( GetDatasheet() ); // alias-specific value else if( aUpdateOtherFields ) schField->SetText( libField->GetText() ); } @@ -1360,12 +1361,13 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList aList.push_back( MSG_PANEL_ITEM( msg, GetValue( currentSheet, true ) ) ); #if 0 // Display symbol flags, for debug only - aList.push_back( MSG_PANEL_ITEM( _( "flags" ), wxString::Format( "%X", - GetEditFlags() ) ) ); + aList.push_back( MSG_PANEL_ITEM( _( "flags" ), + wxString::Format( "%X", GetEditFlags() ) ) ); #endif // Display symbol reference in library and library - aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName() ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Name" ), + UnescapeString( GetLibId().GetLibItemName() ) ) ); if( !m_part->IsRoot() ) { @@ -1376,7 +1378,7 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList if( parent ) msg = parent->GetName(); - aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), msg ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), UnescapeString( msg ) ) ); } else if( !m_lib_id.GetLibNickname().empty() ) { diff --git a/eeschema/sch_validators.cpp b/eeschema/sch_validators.cpp index d000a385ac..56f8fa88d1 100644 --- a/eeschema/sch_validators.cpp +++ b/eeschema/sch_validators.cpp @@ -52,14 +52,7 @@ SCH_FIELD_VALIDATOR::SCH_FIELD_VALIDATOR( bool aIsLibEditor, int aFieldId, wxSt } else if( m_fieldId == SHEETNAME_V ) { - // Does it make sense to exclude the colon and back slash characters? The forward slash - // makes sense because it is used as the separator when generating human readable sheet - // paths. - excludes += wxT( ":/\\" ); - } - else if( aFieldId == VALUE_FIELD && m_isLibEditor ) - { - excludes += wxT( " :/\\" ); + excludes += wxT( "/" ); } long style = GetStyle(); diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 7b17dc39b5..d79353952c 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -72,6 +72,7 @@ #include #include #include +#include bool SYMBOL_EDIT_FRAME::m_showDeMorgan = false; @@ -748,10 +749,10 @@ void SYMBOL_EDIT_FRAME::SetCurSymbol( LIB_SYMBOL* aSymbol, bool aUpdateZoom ) wxString link; msg.Printf( _( "Symbol %s is derived from %s. Symbol graphics will not be editable." ), - symbolName, - parentSymbolName ); + UnescapeString( symbolName ), + UnescapeString( parentSymbolName ) ); - link.Printf( _( "Open %s" ), parentSymbolName ); + link.Printf( _( "Open %s" ), UnescapeString( parentSymbolName ) ); wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY, link, wxEmptyString ); button->Bind( wxEVT_COMMAND_HYPERLINK, std::function( diff --git a/eeschema/symbol_editor/symbol_editor.cpp b/eeschema/symbol_editor/symbol_editor.cpp index 5c8556851f..a915b19ac0 100644 --- a/eeschema/symbol_editor/symbol_editor.cpp +++ b/eeschema/symbol_editor/symbol_editor.cpp @@ -43,7 +43,7 @@ #include #include #include - +#include /** @@ -692,17 +692,15 @@ void SYMBOL_EDIT_FRAME::UpdateAfterSymbolProperties( wxString* aOldName ) { wxCHECK( m_symbol, /* void */ ); - wxString msg; - wxString lib = GetCurLib(); + wxString lib = GetCurLib(); if( !lib.IsEmpty() && aOldName && *aOldName != m_symbol->GetName() ) { // Test the current library for name conflicts if( m_libMgr->SymbolExists( m_symbol->GetName(), lib ) ) { - msg.Printf( _( "The name '%s' conflicts with an existing entry in the library '%s'." ), - m_symbol->GetName(), - lib ); + wxString msg = wxString::Format( _( "Symbol name '%s' already in use." ), + UnescapeString( m_symbol->GetName() ) ); DisplayErrorMessage( this, msg ); m_symbol->SetName( *aOldName ); @@ -1185,14 +1183,14 @@ void SYMBOL_EDIT_FRAME::DisplaySymbolDatasheet() wxString msg = m_symbol->GetName(); - AppendMsgPanel( _( "Name" ), msg, 8 ); + AppendMsgPanel( _( "Name" ), UnescapeString( msg ), 8 ); if( m_symbol->IsAlias() ) { LIB_SYMBOL_SPTR parent = m_symbol->GetParent().lock(); msg = parent ? parent->GetName() : _( "Undefined!" ); - AppendMsgPanel( _( "Parent" ), msg, 8 ); + AppendMsgPanel( _( "Parent" ), UnescapeString( msg ), 8 ); } static wxChar UnitLetter[] = wxT( "?ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); diff --git a/eeschema/symbol_editor/symbol_editor_import_export.cpp b/eeschema/symbol_editor/symbol_editor_import_export.cpp index 95ef995995..e71ff0e70a 100644 --- a/eeschema/symbol_editor/symbol_editor_import_export.cpp +++ b/eeschema/symbol_editor/symbol_editor_import_export.cpp @@ -31,6 +31,7 @@ #include #include #include +#include void SYMBOL_EDIT_FRAME::ImportSymbol() @@ -149,7 +150,7 @@ void SYMBOL_EDIT_FRAME::ExportSymbol() if( old_symbol ) { msg.Printf( _( "Symbol %s already exists in library '%s'." ), - symbol->GetName(), + UnescapeString( symbol->GetName() ), fn.GetFullName() ); KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); @@ -190,7 +191,9 @@ void SYMBOL_EDIT_FRAME::ExportSymbol() m_mruPath = fn.GetPath(); - msg.Printf( _( "Symbol %s saved to library '%s'." ), symbol->GetName(), fn.GetFullPath() ); + msg.Printf( _( "Symbol %s saved to library '%s'." ), + UnescapeString( symbol->GetName() ), + fn.GetFullPath() ); SetStatusText( msg ); // See if the user wants it added to a library table (global or project) diff --git a/eeschema/symbol_editor/symbol_library_manager.cpp b/eeschema/symbol_editor/symbol_library_manager.cpp index 981d2e4768..c763a0ebff 100644 --- a/eeschema/symbol_editor/symbol_library_manager.cpp +++ b/eeschema/symbol_editor/symbol_library_manager.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include "lib_logger.h" @@ -1091,7 +1092,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( } catch( const IO_ERROR& ioe ) { - wxLogError( errorMsg, cachedParent->GetName(), aFileName, ioe.What() ); + wxLogError( errorMsg, UnescapeString( cachedParent->GetName() ), aFileName, + ioe.What() ); return false; } @@ -1101,7 +1103,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( } catch( const IO_ERROR& ioe ) { - wxLogError( errorMsg, newCachedSymbol->GetName(), aFileName, ioe.What() ); + wxLogError( errorMsg, UnescapeString( newCachedSymbol->GetName() ), aFileName, + ioe.What() ); return false; } @@ -1121,7 +1124,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( } catch( const IO_ERROR& ioe ) { - wxLogError( errorMsg, newCachedSymbol->GetName(), aFileName, ioe.What() ); + wxLogError( errorMsg, UnescapeString( newCachedSymbol->GetName() ), aFileName, + ioe.What() ); return false; } @@ -1146,7 +1150,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( } catch( const IO_ERROR& ioe ) { - wxLogError( errorMsg, libSymbol->GetName(), aFileName, ioe.What() ); + wxLogError( errorMsg, UnescapeString( libSymbol->GetName() ), aFileName, + ioe.What() ); return false; } @@ -1163,7 +1168,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( } catch( const IO_ERROR& ioe ) { - wxLogError( errorMsg, libSymbol->GetName(), aFileName, ioe.What() ); + wxLogError( errorMsg, UnescapeString( libSymbol->GetName() ), aFileName, + ioe.What() ); return false; } @@ -1183,7 +1189,8 @@ bool SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::SaveBuffer( } catch( const IO_ERROR& ioe ) { - wxLogError( errorMsg, derivedSymbol->GetName(), aFileName, ioe.What() ); + wxLogError( errorMsg, UnescapeString( derivedSymbol->GetName() ), aFileName, + ioe.What() ); return false; } } @@ -1235,7 +1242,7 @@ void SYMBOL_LIBRARY_MANAGER::LIB_BUFFER::GetRootSymbolNames( wxArrayString& aRoo if( entry->GetSymbol()->IsAlias() ) continue; - aRootSymbolNames.Add( entry->GetSymbol()->GetName() ); + aRootSymbolNames.Add( UnescapeString( entry->GetSymbol()->GetName() ) ); } } diff --git a/eeschema/symbol_tree_synchronizing_adapter.cpp b/eeschema/symbol_tree_synchronizing_adapter.cpp index eb6a0e8c50..5c6a07161d 100644 --- a/eeschema/symbol_tree_synchronizing_adapter.cpp +++ b/eeschema/symbol_tree_synchronizing_adapter.cpp @@ -27,6 +27,7 @@ #include #include #include +#include wxObjectDataPtr @@ -158,10 +159,10 @@ void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::updateLibrary( LIB_TREE_NODE_LIB& aLibNo for( auto nodeIt = aLibNode.m_Children.begin(); nodeIt != aLibNode.m_Children.end(); /**/ ) { auto aliasIt = std::find_if( aliases.begin(), aliases.end(), - [&] ( const LIB_SYMBOL* a ) - { - return a->GetName() == (*nodeIt)->m_Name; - } ); + [&] ( const LIB_SYMBOL* a ) + { + return a->GetName() == (*nodeIt)->m_LibId.GetLibItemName(); + } ); if( aliasIt != aliases.end() ) { @@ -217,9 +218,9 @@ void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataVie node->m_Name = m_frame->GetCurSymbol()->GetLibId().GetLibItemName(); if( node->m_Pinned ) - aVariant = GetPinningSymbol() + node->m_Name; + aVariant = GetPinningSymbol() + UnescapeString( node->m_Name ); else - aVariant = node->m_Name; + aVariant = UnescapeString( node->m_Name ); // mark modified items with an asterisk if( node->m_Type == LIB_TREE_NODE::LIB ) diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index bd32eede4d..2bcc19e9fd 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -55,6 +55,7 @@ #include #include +#include // Save previous symbol library viewer state. wxString SYMBOL_VIEWER_FRAME::m_libraryName; @@ -361,8 +362,8 @@ void SYMBOL_VIEWER_FRAME::updatePreviewSymbol() if( parent ) parentName = parent->GetName(); - AppendMsgPanel( _( "Name" ), m_previewItem->GetName() ); - AppendMsgPanel( _( "Parent" ), parentName ); + AppendMsgPanel( _( "Name" ), UnescapeString( m_previewItem->GetName() ) ); + AppendMsgPanel( _( "Parent" ), UnescapeString( parentName ) ); AppendMsgPanel( _( "Description" ), m_previewItem->GetDescription() ); AppendMsgPanel( _( "Keywords" ), m_previewItem->GetKeyWords() ); } diff --git a/eeschema/tools/symbol_editor_edit_tool.cpp b/eeschema/tools/symbol_editor_edit_tool.cpp index 6898f91ca4..6238c12eb2 100644 --- a/eeschema/tools/symbol_editor_edit_tool.cpp +++ b/eeschema/tools/symbol_editor_edit_tool.cpp @@ -529,7 +529,7 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField ) if( dlg.ShowQuasiModal() != wxID_OK ) return; - wxString newFieldValue = LIB_ID::FixIllegalChars( dlg.GetText() ); + wxString newFieldValue = EscapeString( dlg.GetText(), CTX_LIBID ); wxString oldFieldValue = aField->GetFullText( m_frame->GetUnit() ); bool renamed = aField->GetId() == VALUE_FIELD && newFieldValue != oldFieldValue; @@ -557,9 +557,8 @@ void SYMBOL_EDITOR_EDIT_TOOL::editFieldProperties( LIB_FIELD* aField ) void SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties() { - LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); - bool partLocked = symbol->UnitsLocked(); - wxString oldName = symbol->GetName(); + LIB_SYMBOL* symbol = m_frame->GetCurSymbol(); + bool partLocked = symbol->UnitsLocked(); m_toolMgr->RunAction( ACTIONS::cancelInteractive, true ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); diff --git a/include/lib_id.h b/include/lib_id.h index c3f1fe4e75..09c7a4924b 100644 --- a/include/lib_id.h +++ b/include/lib_id.h @@ -220,7 +220,7 @@ public: * @param aLib True if we are checking library names, false if we are checking item names * @return the corrected version of \a aLibItemName. */ - static UTF8 FixIllegalChars( const UTF8& aLibItemName, bool aLib = false ); + static UTF8 FixIllegalChars( const UTF8& aLibItemName, bool aLib ); /** * Looks for characters that are illegal in library nicknames. diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index 5388b834a1..3c61fcd9a1 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -896,7 +896,7 @@ void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) for( const wxString& filePath : files ) { wxFileName fn( filePath ); - wxString nickname = LIB_ID::FixIllegalChars( fn.GetName() ); + wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), true ); bool doAdd = true; if( cur_model()->ContainsNickname( nickname ) )