Fix some more missing escaping for symbol ids.
Fixes https://gitlab.com/kicad/code/kicad/issues/8694
This commit is contained in:
parent
36d66085f5
commit
6d4c454e8c
|
@ -30,6 +30,7 @@
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
#include <kiway.h>
|
#include <kiway.h>
|
||||||
#include <kiway_player.h>
|
#include <kiway_player.h>
|
||||||
|
#include <kicad_string.h>
|
||||||
#include <dialog_shim.h>
|
#include <dialog_shim.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <env_paths.h>
|
#include <env_paths.h>
|
||||||
|
@ -189,18 +190,26 @@ protected:
|
||||||
m_popup = nullptr;
|
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
|
void OnButtonClick() override
|
||||||
{
|
{
|
||||||
// pick a footprint using the footprint picker.
|
// pick a symbol using the symbol picker.
|
||||||
wxString compid = GetValue();
|
wxString rawValue = GetValue();
|
||||||
|
|
||||||
if( compid.IsEmpty() )
|
if( rawValue.IsEmpty() )
|
||||||
compid = m_preselect;
|
rawValue = m_preselect;
|
||||||
|
|
||||||
|
wxString symbolId = escapeLibId( rawValue );
|
||||||
KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_SCH_VIEWER_MODAL, true, m_dlg );
|
KIWAY_PLAYER* frame = m_dlg->Kiway().Player( FRAME_SCH_VIEWER_MODAL, true, m_dlg );
|
||||||
|
|
||||||
if( frame->ShowModal( &compid, m_dlg ) )
|
if( frame->ShowModal( &symbolId, m_dlg ) )
|
||||||
SetValue( compid );
|
SetValue( symbolId );
|
||||||
|
|
||||||
frame->Destroy();
|
frame->Destroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,14 @@ DIALOG_LIB_NEW_SYMBOL::DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* aParent,
|
||||||
m_staticPinTextPositionUnits, true )
|
m_staticPinTextPositionUnits, true )
|
||||||
{
|
{
|
||||||
if( aRootSymbolNames && aRootSymbolNames->GetCount() )
|
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_textName->SetValidator( SCH_FIELD_VALIDATOR( true, VALUE_FIELD ) );
|
||||||
m_textReference->SetValidator( SCH_FIELD_VALIDATOR( true, REFERENCE_FIELD ) );
|
m_textReference->SetValidator( SCH_FIELD_VALIDATOR( true, REFERENCE_FIELD ) );
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#define __dialog_lib_new_symbol__
|
#define __dialog_lib_new_symbol__
|
||||||
|
|
||||||
#include <widgets/unit_binder.h>
|
#include <widgets/unit_binder.h>
|
||||||
|
#include <kicad_string.h>
|
||||||
#include <dialog_lib_new_symbol_base.h>
|
#include <dialog_lib_new_symbol_base.h>
|
||||||
|
|
||||||
class EDA_DRAW_FRAME;
|
class EDA_DRAW_FRAME;
|
||||||
|
@ -38,33 +38,31 @@ public:
|
||||||
DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* parent,
|
DIALOG_LIB_NEW_SYMBOL( EDA_DRAW_FRAME* parent,
|
||||||
const wxArrayString* aRootSymbolNames = nullptr );
|
const wxArrayString* aRootSymbolNames = nullptr );
|
||||||
|
|
||||||
void SetName( const wxString& name ) override { m_textName->SetValue( name ); }
|
void SetName( const wxString& name ) override
|
||||||
wxString GetName( void ) const override { return m_textName->GetValue(); }
|
|
||||||
|
|
||||||
wxString GetParentSymbolName() const { return m_comboInheritanceSelect->GetValue(); }
|
|
||||||
|
|
||||||
void SetReference( const wxString& reference )
|
|
||||||
{
|
{
|
||||||
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(); }
|
wxString GetReference( void ) { return m_textReference->GetValue(); }
|
||||||
|
|
||||||
void SetPartCount( int count ) { m_spinPartCount->SetValue( count ); }
|
void SetPartCount( int count ) { m_spinPartCount->SetValue( count ); }
|
||||||
int GetUnitCount( void ) { return m_spinPartCount->GetValue(); }
|
int GetUnitCount( void ) { return m_spinPartCount->GetValue(); }
|
||||||
|
|
||||||
void SetAlternateBodyStyle( bool enable )
|
void SetAlternateBodyStyle( bool enable ) { m_checkHasConversion->SetValue( enable ); }
|
||||||
{
|
bool GetAlternateBodyStyle( void ) { return m_checkHasConversion->GetValue(); }
|
||||||
m_checkHasConversion->SetValue( enable );
|
|
||||||
}
|
|
||||||
bool GetAlternateBodyStyle( void )
|
|
||||||
{
|
|
||||||
return m_checkHasConversion->GetValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetPowerSymbol( bool enable )
|
void SetPowerSymbol( bool enable ) { m_checkIsPowerSymbol->SetValue( enable ); }
|
||||||
{
|
|
||||||
m_checkIsPowerSymbol->SetValue( enable );
|
|
||||||
}
|
|
||||||
bool GetPowerSymbol( void ) { return m_checkIsPowerSymbol->GetValue(); }
|
bool GetPowerSymbol( void ) { return m_checkIsPowerSymbol->GetValue(); }
|
||||||
|
|
||||||
void SetLockItems( bool enable ) { m_checkLockItems->SetValue( enable ); }
|
void SetLockItems( bool enable ) { m_checkLockItems->SetValue( enable ); }
|
||||||
|
@ -76,28 +74,16 @@ public:
|
||||||
void SetIncludeOnBoard( bool aInclude ) { m_excludeFromBoardCheckBox->SetValue( !aInclude ); }
|
void SetIncludeOnBoard( bool aInclude ) { m_excludeFromBoardCheckBox->SetValue( !aInclude ); }
|
||||||
bool GetIncludeOnBoard() const { return !m_excludeFromBoardCheckBox->GetValue(); }
|
bool GetIncludeOnBoard() const { return !m_excludeFromBoardCheckBox->GetValue(); }
|
||||||
|
|
||||||
void SetPinTextPosition( int position )
|
void SetPinTextPosition( int position ) { m_pinTextPosition.SetValue( position ); }
|
||||||
{
|
|
||||||
m_pinTextPosition.SetValue( position );
|
|
||||||
}
|
|
||||||
int GetPinTextPosition( void ) { return m_pinTextPosition.GetValue(); }
|
int GetPinTextPosition( void ) { return m_pinTextPosition.GetValue(); }
|
||||||
|
|
||||||
void SetShowPinNumber( bool show )
|
void SetShowPinNumber( bool show ) { m_checkShowPinNumber->SetValue( show ); }
|
||||||
{
|
|
||||||
m_checkShowPinNumber->SetValue( show );
|
|
||||||
}
|
|
||||||
bool GetShowPinNumber( void ) { return m_checkShowPinNumber->GetValue(); }
|
bool GetShowPinNumber( void ) { return m_checkShowPinNumber->GetValue(); }
|
||||||
|
|
||||||
void SetShowPinName( bool show )
|
void SetShowPinName( bool show ) { m_checkShowPinName->SetValue( show ); }
|
||||||
{
|
|
||||||
m_checkShowPinName->SetValue( show );
|
|
||||||
}
|
|
||||||
bool GetShowPinName( void ) { return m_checkShowPinName->GetValue(); }
|
bool GetShowPinName( void ) { return m_checkShowPinName->GetValue(); }
|
||||||
|
|
||||||
void SetPinNameInside( bool show )
|
void SetPinNameInside( bool show ) { m_checkShowPinNameInside->SetValue( show ); }
|
||||||
{
|
|
||||||
m_checkShowPinNameInside->SetValue( show );
|
|
||||||
}
|
|
||||||
bool GetPinNameInside( void ) { return m_checkShowPinNameInside->GetValue(); }
|
bool GetPinNameInside( void ) { return m_checkShowPinNameInside->GetValue(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -704,7 +704,7 @@ int ERC_TESTER::TestLibSymbolIssues()
|
||||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||||
ercItem->SetItems( symbol );
|
ercItem->SetItems( symbol );
|
||||||
msg.Printf( _( "The current configuration does not include the library '%s'." ),
|
msg.Printf( _( "The current configuration does not include the library '%s'." ),
|
||||||
libName );
|
UnescapeString( libName ) );
|
||||||
ercItem->SetErrorMessage( msg );
|
ercItem->SetErrorMessage( msg );
|
||||||
|
|
||||||
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
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 );
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||||
ercItem->SetItems( symbol );
|
ercItem->SetItems( symbol );
|
||||||
msg.Printf( _( "The library '%s' is not enabled in the current configuration." ),
|
msg.Printf( _( "The library '%s' is not enabled in the current configuration." ),
|
||||||
libName );
|
UnescapeString( libName ) );
|
||||||
ercItem->SetErrorMessage( msg );
|
ercItem->SetErrorMessage( msg );
|
||||||
|
|
||||||
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
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 );
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||||
ercItem->SetItems( symbol );
|
ercItem->SetItems( symbol );
|
||||||
msg.Printf( "Symbol '%s' not found in symbol library '%s'.",
|
msg.Printf( "Symbol '%s' not found in symbol library '%s'.",
|
||||||
symbolName,
|
UnescapeString( symbolName ),
|
||||||
libName );
|
UnescapeString( libName ) );
|
||||||
ercItem->SetErrorMessage( msg );
|
ercItem->SetErrorMessage( msg );
|
||||||
|
|
||||||
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
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 );
|
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||||
ercItem->SetItems( symbol );
|
ercItem->SetItems( symbol );
|
||||||
msg.Printf( "Symbol '%s' has been modified in library '%s'.",
|
msg.Printf( "Symbol '%s' has been modified in library '%s'.",
|
||||||
symbolName,
|
UnescapeString( symbolName ),
|
||||||
libName );
|
UnescapeString( libName ) );
|
||||||
ercItem->SetErrorMessage( msg );
|
ercItem->SetErrorMessage( msg );
|
||||||
|
|
||||||
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
||||||
|
|
|
@ -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"
|
msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n"
|
||||||
"Use Manage Symbol Libraries to edit the configuration." ),
|
"Use Manage Symbol Libraries to edit the configuration." ),
|
||||||
libNickname );
|
UnescapeString( libNickname ) );
|
||||||
DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
|
DisplayErrorMessage( this, _( "Symbol library not enabled." ), msg );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
msg.Printf( _( "The current configuration does not include the library '%s'.\n"
|
||||||
"Use Manage Symbol Libraries to edit the configuration." ),
|
"Use Manage Symbol Libraries to edit the configuration." ),
|
||||||
libName );
|
UnescapeString( libName ) );
|
||||||
DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
|
DisplayErrorMessage( this, _( "Library not found in symbol library table." ), msg );
|
||||||
}
|
}
|
||||||
else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
|
else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n"
|
msg.Printf( _( "The library '%s' is not enabled in the current configuration.\n"
|
||||||
"Use Manage Symbol Libraries to edit the configuration." ),
|
"Use Manage Symbol Libraries to edit the configuration." ),
|
||||||
libName );
|
UnescapeString( libName ) );
|
||||||
DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
|
DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#define __LIB_TABLE_GRID_H__
|
#define __LIB_TABLE_GRID_H__
|
||||||
|
|
||||||
#include <lib_table_base.h>
|
#include <lib_table_base.h>
|
||||||
|
#include <kicad_string.h>
|
||||||
#include <wx/grid.h>
|
#include <wx/grid.h>
|
||||||
|
|
||||||
const wxColour COLOUR_ROW_ENABLED( 0, 0, 0 );
|
const wxColour COLOUR_ROW_ENABLED( 0, 0, 0 );
|
||||||
|
@ -62,15 +62,13 @@ public:
|
||||||
|
|
||||||
switch( aCol )
|
switch( aCol )
|
||||||
{
|
{
|
||||||
case COL_NICKNAME: return r->GetNickName();
|
case COL_NICKNAME: return UnescapeString( r->GetNickName() );
|
||||||
case COL_URI: return r->GetFullURI();
|
case COL_URI: return r->GetFullURI();
|
||||||
case COL_TYPE: return r->GetType();
|
case COL_TYPE: return r->GetType();
|
||||||
case COL_OPTIONS: return r->GetOptions();
|
case COL_OPTIONS: return r->GetOptions();
|
||||||
case COL_DESCR: return r->GetDescr();
|
case COL_DESCR: return r->GetDescr();
|
||||||
// Render a boolean value as its text equivalent
|
case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" );
|
||||||
case COL_ENABLED: return r->GetIsEnabled() ? wxT( "1" ) : wxT( "0" );
|
default: return wxEmptyString;
|
||||||
default:
|
|
||||||
; // fall thru to wxEmptyString
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,14 +91,12 @@ public:
|
||||||
|
|
||||||
switch( aCol )
|
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_URI: r->SetFullURI( aValue ); break;
|
||||||
case COL_TYPE: r->SetType( aValue ); break;
|
case COL_TYPE: r->SetType( aValue ); break;
|
||||||
case COL_OPTIONS: r->SetOptions( aValue ); break;
|
case COL_OPTIONS: r->SetOptions( aValue ); break;
|
||||||
case COL_DESCR: r->SetDescr( aValue ); break;
|
case COL_DESCR: r->SetDescr( aValue ); break;
|
||||||
case COL_ENABLED:
|
case COL_ENABLED: r->SetEnabled( aValue == wxT( "1" ) ); break;
|
||||||
r->SetEnabled( aValue == wxT( "1" ) );
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue