diff --git a/common/widgets/grid_text_button_helpers.cpp b/common/widgets/grid_text_button_helpers.cpp index ae01329058..678525b208 100644 --- a/common/widgets/grid_text_button_helpers.cpp +++ b/common/widgets/grid_text_button_helpers.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -189,18 +190,26 @@ protected: m_popup = nullptr; } + wxString escapeLibId( const wxString& aRawValue ) + { + wxString itemName; + wxString libName = aRawValue.BeforeFirst( ':', &itemName ); + return EscapeString( libName, CTX_LIBID ) + ':' + EscapeString( itemName, CTX_LIBID ); + } + void OnButtonClick() override { - // pick a footprint using the footprint picker. - wxString compid = GetValue(); + // pick a symbol using the symbol picker. + wxString rawValue = GetValue(); - if( compid.IsEmpty() ) - compid = m_preselect; + if( rawValue.IsEmpty() ) + rawValue = m_preselect; + wxString symbolId = escapeLibId( rawValue ); KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_SCH_VIEWER_MODAL, true, m_dlg ); - if( frame->ShowModal( &compid, m_dlg ) ) - SetValue( compid ); + if( frame->ShowModal( &symbolId, m_dlg ) ) + SetValue( symbolId ); frame->Destroy(); } diff --git a/eeschema/dialogs/dialog_lib_new_symbol.cpp b/eeschema/dialogs/dialog_lib_new_symbol.cpp index d56ab30c94..0b3b07f70d 100644 --- a/eeschema/dialogs/dialog_lib_new_symbol.cpp +++ b/eeschema/dialogs/dialog_lib_new_symbol.cpp @@ -35,7 +35,14 @@ DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent, m_staticPinTextPositionUnits, true ) { if( aRootSymbolNames && aRootSymbolNames->GetCount() ) - m_comboInheritanceSelect->Append( *aRootSymbolNames ); + { + wxArrayString escapedNames; + + for( const wxString& name : *aRootSymbolNames ) + escapedNames.Add( UnescapeString( name ) ); + + m_comboInheritanceSelect->Append( escapedNames ); + } m_textName->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE_FIELD ) ); m_textReference->SetValidator( SCH_FIELD_VALIDATOR( true, REFERENCE_FIELD ) ); diff --git a/eeschema/dialogs/dialog_lib_new_symbol.h b/eeschema/dialogs/dialog_lib_new_symbol.h index c4cbe11828..c673f4c72c 100644 --- a/eeschema/dialogs/dialog_lib_new_symbol.h +++ b/eeschema/dialogs/dialog_lib_new_symbol.h @@ -26,7 +26,7 @@ #define __dialog_lib_new_symbol__ #include - +#include #include class EDA_DRAW_FRAME; @@ -38,33 +38,31 @@ public: DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* parent, const wxArrayString* aRootSymbolNames = nullptr ); - void SetName( const wxString& name ) override { m_textName->SetValue( name ); } - wxString GetName( void ) const override { return m_textName->GetValue(); } - - wxString GetParentSymbolName() const { return m_comboInheritanceSelect->GetValue(); } - - void SetReference( const wxString& reference ) + void SetName( const wxString& name ) override { - m_textReference->SetValue( reference ); + m_textName->SetValue( UnescapeString( name ) ); } + + wxString GetName( void ) const override + { + return EscapeString( m_textName->GetValue(), CTX_LIBID ); + } + + wxString GetParentSymbolName() const + { + return EscapeString( m_comboInheritanceSelect->GetValue(), CTX_LIBID ); + } + + void SetReference( const wxString& reference ) { m_textReference->SetValue( reference ); } wxString GetReference( void ) { return m_textReference->GetValue(); } void SetPartCount( int count ) { m_spinPartCount->SetValue( count ); } int GetUnitCount( void ) { return m_spinPartCount->GetValue(); } - void SetAlternateBodyStyle( bool enable ) - { - m_checkHasConversion->SetValue( enable ); - } - bool GetAlternateBodyStyle( void ) - { - return m_checkHasConversion->GetValue(); - } + void SetAlternateBodyStyle( bool enable ) { m_checkHasConversion->SetValue( enable ); } + bool GetAlternateBodyStyle( void ) { return m_checkHasConversion->GetValue(); } - void SetPowerSymbol( bool enable ) - { - m_checkIsPowerSymbol->SetValue( enable ); - } + void SetPowerSymbol( bool enable ) { m_checkIsPowerSymbol->SetValue( enable ); } bool GetPowerSymbol( void ) { return m_checkIsPowerSymbol->GetValue(); } void SetLockItems( bool enable ) { m_checkLockItems->SetValue( enable ); } @@ -76,28 +74,16 @@ public: void SetIncludeOnBoard( bool aInclude ) { m_excludeFromBoardCheckBox->SetValue( !aInclude ); } bool GetIncludeOnBoard() const { return !m_excludeFromBoardCheckBox->GetValue(); } - void SetPinTextPosition( int position ) - { - m_pinTextPosition.SetValue( position ); - } + void SetPinTextPosition( int position ) { m_pinTextPosition.SetValue( position ); } int GetPinTextPosition( void ) { return m_pinTextPosition.GetValue(); } - void SetShowPinNumber( bool show ) - { - m_checkShowPinNumber->SetValue( show ); - } + void SetShowPinNumber( bool show ) { m_checkShowPinNumber->SetValue( show ); } bool GetShowPinNumber( void ) { return m_checkShowPinNumber->GetValue(); } - void SetShowPinName( bool show ) - { - m_checkShowPinName->SetValue( show ); - } + void SetShowPinName( bool show ) { m_checkShowPinName->SetValue( show ); } bool GetShowPinName( void ) { return m_checkShowPinName->GetValue(); } - void SetPinNameInside( bool show ) - { - m_checkShowPinNameInside->SetValue( show ); - } + void SetPinNameInside( bool show ) { m_checkShowPinNameInside->SetValue( show ); } bool GetPinNameInside( void ) { return m_checkShowPinNameInside->GetValue(); } protected: diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 943040a748..95cbbd6281 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -704,7 +704,7 @@ int ERC_TESTER::TestLibSymbolIssues() std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES ); ercItem->SetItems( symbol ); msg.Printf( _( "The current configuration does not include the library '%s'." ), - libName ); + UnescapeString( libName ) ); ercItem->SetErrorMessage( msg ); markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) ); @@ -715,7 +715,7 @@ int ERC_TESTER::TestLibSymbolIssues() std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES ); ercItem->SetItems( symbol ); msg.Printf( _( "The library '%s' is not enabled in the current configuration." ), - libName ); + UnescapeString( libName ) ); ercItem->SetErrorMessage( msg ); markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) ); @@ -730,8 +730,8 @@ int ERC_TESTER::TestLibSymbolIssues() std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES ); ercItem->SetItems( symbol ); msg.Printf( "Symbol '%s' not found in symbol library '%s'.", - symbolName, - libName ); + UnescapeString( symbolName ), + UnescapeString( libName ) ); ercItem->SetErrorMessage( msg ); markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) ); @@ -745,8 +745,8 @@ int ERC_TESTER::TestLibSymbolIssues() std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES ); ercItem->SetItems( symbol ); msg.Printf( "Symbol '%s' has been modified in library '%s'.", - symbolName, - libName ); + UnescapeString( symbolName ), + UnescapeString( libName ) ); ercItem->SetErrorMessage( msg ); markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) ); diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index dc801d7461..b18700bfe4 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -1194,7 +1194,7 @@ void SYMBOL_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) { msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n" "Use Manage Symbol Libraries to edit the configuration." ), - libNickname ); + UnescapeString( libNickname ) ); DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg ); break; } diff --git a/eeschema/symbol_viewer_frame.cpp b/eeschema/symbol_viewer_frame.cpp index 55bae28852..d3da1121b5 100644 --- a/eeschema/symbol_viewer_frame.cpp +++ b/eeschema/symbol_viewer_frame.cpp @@ -392,14 +392,14 @@ bool SYMBOL_VIEWER_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent ) { msg.Printf( _( "The current configuration does not include the library '%s'.\n" "Use Manage Symbol Libraries to edit the configuration." ), - libName ); + UnescapeString( libName ) ); DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg ); } else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) ) { msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n" "Use Manage Symbol Libraries to edit the configuration." ), - libName ); + UnescapeString( libName ) ); DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg ); } else diff --git a/include/lib_table_grid.h b/include/lib_table_grid.h index e7107d9c17..00f8aadda9 100644 --- a/include/lib_table_grid.h +++ b/include/lib_table_grid.h @@ -21,7 +21,7 @@ #define __LIB_TABLE_GRID_H__ #include - +#include #include const wxColour COLOUR_ROW_ENABLED( 0, 0, 0 ); @@ -62,15 +62,13 @@ public: switch( aCol ) { - case COL_NICKNAME: return r->GetNickName(); - case COL_URI: return r->GetFullURI(); - case COL_TYPE: return r->GetType(); - case COL_OPTIONS: return r->GetOptions(); - case COL_DESCR: return r->GetDescr(); - // Render a boolean value as its text equivalent - case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" ); - default: - ; // fall thru to wxEmptyString + case COL_NICKNAME: return UnescapeString( r->GetNickName() ); + case COL_URI: return r->GetFullURI(); + case COL_TYPE: return r->GetType(); + case COL_OPTIONS: return r->GetOptions(); + case COL_DESCR: return r->GetDescr(); + case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" ); + default: return wxEmptyString; } } @@ -93,14 +91,12 @@ public: switch( aCol ) { - case COL_NICKNAME: r->SetNickName( aValue ); break; - case COL_URI: r->SetFullURI( aValue ); break; - case COL_TYPE: r->SetType( aValue ); break; - case COL_OPTIONS: r->SetOptions( aValue ); break; - case COL_DESCR: r->SetDescr( aValue ); break; - case COL_ENABLED: - r->SetEnabled( aValue == wxT( "1" ) ); - break; + case COL_NICKNAME: r->SetNickName( EscapeString( aValue, CTX_LIBID ) ); break; + case COL_URI: r->SetFullURI( aValue ); break; + case COL_TYPE: r->SetType( aValue ); break; + case COL_OPTIONS: r->SetOptions( aValue ); break; + case COL_DESCR: r->SetDescr( aValue ); break; + case COL_ENABLED: r->SetEnabled( aValue == wxT( "1" ) ); break; } } }