From a9eb7a0e28f7b142739b2c8d619dcd08fadb88ce Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 10 Mar 2022 13:45:03 +0000 Subject: [PATCH] Make sure LIB_ID escape context allows for formatting constructs. Also make sure that value field is updated from name changes when the symbol is a power symbol (even if it's from the schematic instead of the library). Fixes https://gitlab.com/kicad/code/kicad/issues/11093 --- common/string_utils.cpp | 14 ++++++++++++-- eeschema/dialogs/dialog_lib_symbol_properties.cpp | 2 +- eeschema/fields_grid_table.cpp | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/common/string_utils.cpp b/common/string_utils.cpp index 27593d4d4c..6fdcc344f1 100644 --- a/common/string_utils.cpp +++ b/common/string_utils.cpp @@ -142,7 +142,15 @@ bool ConvertSmartQuotesAndDashes( wxString* aString ) wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ) { - wxString converted; + wxString converted; + std::vector braceStack; // true == formatting construct + + auto hasFormattingPrefix = + [&]() + { + static wxString prefixes = wxT( "~_^" ); + return !converted.IsEmpty() && prefixes.Find( converted.Last() ) >= 0; + }; converted.reserve( aSource.length() ); @@ -159,7 +167,7 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ) } else if( aContext == CTX_LIBID ) { - if( c == '{' ) + if( c == '{' && !hasFormattingPrefix() ) converted += "{brace}"; else if( c == '/' ) converted += "{slash}"; @@ -238,7 +246,9 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ) converted += c; } else + { converted += c; + } } return converted; diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index f4410236f0..38d17ede6e 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -446,7 +446,7 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::OnGridCellChanging( wxGridEvent& event ) void DIALOG_LIB_SYMBOL_PROPERTIES::OnSymbolNameText( wxCommandEvent& event ) { - if( !m_Parent->IsSymbolFromSchematic() ) + if( !m_Parent->IsSymbolFromSchematic() || m_OptionPower->IsChecked() ) m_grid->SetCellValue( VALUE_FIELD, FDC_VALUE, m_SymbolNameCtrl->GetValue() ); } diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index 0c0aaa767c..098a25d257 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -561,7 +561,7 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue value = fn.GetFullPath(); } } - else if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) && aRow == VALUE_FIELD ) + else if( m_parentType == SCH_SYMBOL_T && aRow == VALUE_FIELD ) { value = EscapeString( value, CTX_LIBID ); }