Fix some more missing escaping for symbol ids.

Fixes https://gitlab.com/kicad/code/kicad/issues/8694
This commit is contained in:
Jeff Young 2021-07-28 18:36:13 +01:00
parent 36d66085f5
commit 6d4c454e8c
7 changed files with 68 additions and 70 deletions

View File

@ -30,6 +30,7 @@
#include <bitmaps.h>
#include <kiway.h>
#include <kiway_player.h>
#include <kicad_string.h>
#include <dialog_shim.h>
#include <common.h>
#include <env_paths.h>
@ -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();
}

View File

@ -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 ) );

View File

@ -26,7 +26,7 @@
#define __dialog_lib_new_symbol__
#include <widgets/unit_binder.h>
#include <kicad_string.h>
#include <dialog_lib_new_symbol_base.h>
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:

View File

@ -704,7 +704,7 @@ int ERC_TESTER::TestLibSymbolIssues()
std::shared_ptr<ERC_ITEM> 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<ERC_ITEM> 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<ERC_ITEM> 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<ERC_ITEM> 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() ) );

View File

@ -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;
}

View File

@ -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

View File

@ -21,7 +21,7 @@
#define __LIB_TABLE_GRID_H__
#include <lib_table_base.h>
#include <kicad_string.h>
#include <wx/grid.h>
const wxColour COLOUR_ROW_ENABLED( 0, 0, 0 );
@ -62,15 +62,13 @@ public:
switch( aCol )
{
case COL_NICKNAME: return r->GetNickName();
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();
// Render a boolean value as its text equivalent
case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" );
default:
; // fall thru to wxEmptyString
default: return wxEmptyString;
}
}
@ -93,14 +91,12 @@ public:
switch( aCol )
{
case COL_NICKNAME: r->SetNickName( aValue ); 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;
case COL_ENABLED: r->SetEnabled( aValue == wxT( "1" ) ); break;
}
}
}