From 02b1f552fd293f3510454ab33668060bc7a4489f 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 (cherry picked from commit a9eb7a0e28f7b142739b2c8d619dcd08fadb88ce) (cherry picked from commit 02252be29d2651ab3d8c09d98891d4ce7005e603) --- 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 a8f17bc183..552a228e08 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 += wxT( "{brace}" ); else if( c == '/' ) converted += wxT( "{slash}" ); @@ -227,7 +235,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 2f20ed2621..42b15e9f58 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -448,7 +448,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 9c5f95471e..9dee31f719 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -502,7 +502,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 ); }