Eeschema: fix schematic I/O plugin symbol name issue.
LIB_ID was changing the symbol name due to the parser dropping everything past the first '/' character which is interpreted by LIB_ID as the item version. Add flag to ignore this in LIB_ID::SetLibItemName() and add a new ctor so the library nickname, item name, and revision can be set as required to prevent the standard LIB_ID parsing. Fix a few places where PART_LIBS functions FindLibraryAlias() and FindLibPar() were translating wxString symbol names to LIB_IDs where the LIB_ID parser was truncating the symbol name.
This commit is contained in:
parent
37c086896e
commit
eb06b35852
|
@ -207,6 +207,15 @@ LIB_ID::LIB_ID( const wxString& aId ) throw( PARSE_ERROR )
|
|||
}
|
||||
|
||||
|
||||
LIB_ID::LIB_ID( const wxString& aLibName, const wxString& aLibItemName,
|
||||
const wxString& aRevision ) :
|
||||
nickname( aLibName ),
|
||||
item_name( aLibItemName ),
|
||||
revision( aRevision )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int LIB_ID::SetLibNickname( const UTF8& aLogical )
|
||||
{
|
||||
int offset = okLogical( aLogical );
|
||||
|
@ -220,11 +229,11 @@ int LIB_ID::SetLibNickname( const UTF8& aLogical )
|
|||
}
|
||||
|
||||
|
||||
int LIB_ID::SetLibItemName( const UTF8& aLibItemName )
|
||||
int LIB_ID::SetLibItemName( const UTF8& aLibItemName, bool aTestForRev )
|
||||
{
|
||||
int separation = int( aLibItemName.find_first_of( "/" ) );
|
||||
|
||||
if( separation != -1 )
|
||||
if( aTestForRev && separation != -1 )
|
||||
{
|
||||
item_name = aLibItemName.substr( 0, separation-1 );
|
||||
return separation;
|
||||
|
|
|
@ -171,7 +171,7 @@ void COMPONENT_TREE_SEARCH_CONTAINER::AddAliasList( const wxString& aNodeName,
|
|||
if( aOptionalLib )
|
||||
a = aOptionalLib->FindAlias( aName );
|
||||
else
|
||||
a = m_libs->FindLibraryAlias( aName, wxEmptyString );
|
||||
a = m_libs->FindLibraryAlias( LIB_ID( wxEmptyString, aName ), wxEmptyString );
|
||||
|
||||
if( a == NULL )
|
||||
continue;
|
||||
|
|
|
@ -340,7 +340,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
|
|||
|
||||
tmp.Replace( wxT( " " ), wxT( "_" ) );
|
||||
|
||||
id.SetLibItemName( tmp );
|
||||
id.SetLibItemName( tmp, false );
|
||||
|
||||
// Save current flags which could be modified by next change settings
|
||||
STATUS_FLAGS flags = m_cmp->GetFlags();
|
||||
|
|
|
@ -157,7 +157,8 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const SCHLIB_FILTER* aFilte
|
|||
search_container.SetPreselectNode( aHighlight, /* aUnit */ 0 );
|
||||
|
||||
const int deMorgan = aConvert ? *aConvert : 1;
|
||||
dialogTitle.Printf( _( "Choose Component (%d items loaded)" ), search_container.GetComponentsCount() );
|
||||
dialogTitle.Printf( _( "Choose Component (%d items loaded)" ),
|
||||
search_container.GetComponentsCount() );
|
||||
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, &search_container, deMorgan );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
|
@ -174,7 +175,9 @@ wxString SCH_BASE_FRAME::SelectComponentFromLibrary( const SCHLIB_FILTER* aFilte
|
|||
if( !cmpName.empty() )
|
||||
{
|
||||
AddHistoryComponentName( aHistoryList, cmpName );
|
||||
if ( aUnit ) aHistoryLastUnit = *aUnit;
|
||||
|
||||
if ( aUnit )
|
||||
aHistoryLastUnit = *aUnit;
|
||||
}
|
||||
|
||||
return cmpName;
|
||||
|
@ -210,7 +213,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
|
|||
if( aFilter )
|
||||
libsource = aFilter->GetLibSource();
|
||||
|
||||
LIB_PART* part = Prj().SchLibs()->FindLibPart( name, libsource );
|
||||
LIB_PART* part = Prj().SchLibs()->FindLibPart( LIB_ID( wxEmptyString, name ), libsource );
|
||||
|
||||
if( !part )
|
||||
{
|
||||
|
@ -230,7 +233,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
|
|||
// alias exists because its root component was found
|
||||
LIB_ID libId;
|
||||
|
||||
libId.SetLibItemName( name );
|
||||
libId.SetLibItemName( name, false );
|
||||
component->SetLibId( libId );
|
||||
|
||||
// Be sure the link to the corresponding LIB_PART is OK:
|
||||
|
|
|
@ -154,7 +154,7 @@ void LIB_EDIT_FRAME::LoadOneLibraryPart( wxCommandEvent& event )
|
|||
{
|
||||
// Not found in the active library: search inside the full list
|
||||
// (can happen when using Viewlib to load a component)
|
||||
libEntry = Prj().SchLibs()->FindLibraryAlias( cmp_name );
|
||||
libEntry = Prj().SchLibs()->FindLibraryAlias( LIB_ID( wxEmptyString, cmp_name ) );
|
||||
|
||||
if( libEntry )
|
||||
{
|
||||
|
|
|
@ -986,7 +986,7 @@ LIB_PART* LIB_EDIT_FRAME::GetCurPart()
|
|||
wxString name = Prj().GetRString( PROJECT::SCH_LIBEDIT_CUR_PART );
|
||||
LIB_PART* part;
|
||||
|
||||
if( !!name && ( part = Prj().SchLibs()->FindLibPart( name ) ) )
|
||||
if( !!name && ( part = Prj().SchLibs()->FindLibPart( LIB_ID( wxEmptyString, name ) ) ) )
|
||||
{
|
||||
// clone it from the PART_LIB and own it.
|
||||
m_my_part = new LIB_PART( *part );
|
||||
|
|
|
@ -239,8 +239,8 @@ public:
|
|||
for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) )
|
||||
{
|
||||
wxString part_name( each_component->GetLibId().GetLibItemName() );
|
||||
|
||||
LIB_ALIAS* case_sensitive_match = aRescuer.GetLibs()->FindLibraryAlias( part_name );
|
||||
LIB_ID id( wxEmptyString, part_name );
|
||||
LIB_ALIAS* case_sensitive_match = aRescuer.GetLibs()->FindLibraryAlias( id );
|
||||
std::vector<LIB_ALIAS*> case_insensitive_matches;
|
||||
aRescuer.GetLibs()->FindLibraryNearEntries( case_insensitive_matches, part_name );
|
||||
|
||||
|
@ -293,7 +293,7 @@ public:
|
|||
|
||||
LIB_ID libId;
|
||||
|
||||
libId.SetLibItemName( m_new_name );
|
||||
libId.SetLibItemName( m_new_name, false );
|
||||
each_component->SetLibId( libId );
|
||||
each_component->ClearFlags();
|
||||
aRescuer->LogRescue( each_component, m_requested_name, m_new_name );
|
||||
|
@ -330,8 +330,10 @@ public:
|
|||
{
|
||||
wxString part_name( each_component->GetLibId().GetLibItemName() );
|
||||
|
||||
LIB_PART* cache_match = find_component( part_name, aRescuer.GetLibs(), /* aCached */ true );
|
||||
LIB_PART* lib_match = aRescuer.GetLibs()->FindLibPart( part_name );
|
||||
LIB_PART* cache_match = find_component( part_name,
|
||||
aRescuer.GetLibs(), /* aCached */ true );
|
||||
LIB_ID id( wxEmptyString, part_name );
|
||||
LIB_PART* lib_match = aRescuer.GetLibs()->FindLibPart( id );
|
||||
|
||||
// Test whether there is a conflict
|
||||
if( !cache_match || !lib_match )
|
||||
|
@ -413,7 +415,7 @@ public:
|
|||
|
||||
LIB_ID libId;
|
||||
|
||||
libId.SetLibItemName( m_new_name );
|
||||
libId.SetLibItemName( m_new_name, false );
|
||||
each_component->SetLibId( libId );
|
||||
each_component->ClearFlags();
|
||||
aRescuer->LogRescue( each_component, m_requested_name, m_new_name );
|
||||
|
@ -489,7 +491,7 @@ void RESCUER::UndoRescues()
|
|||
{
|
||||
LIB_ID libId;
|
||||
|
||||
libId.SetLibItemName( each_logitem.old_name );
|
||||
libId.SetLibItemName( each_logitem.old_name, false );
|
||||
each_logitem.component->SetLibId( libId );
|
||||
each_logitem.component->ClearFlags();
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* sheet, int unit,
|
|||
|
||||
m_unit = unit;
|
||||
m_convert = convert;
|
||||
m_lib_id.SetLibItemName( aPart.GetName() );
|
||||
m_lib_id.SetLibItemName( aPart.GetName(), false );
|
||||
m_part = aPart.SharedPtr();
|
||||
m_currentSheetPath = NULL;
|
||||
m_fieldsAutoplaced = AUTOPLACED_NO;
|
||||
|
@ -275,7 +275,7 @@ bool SCH_COMPONENT::Resolve( PART_LIBS* aLibs )
|
|||
{
|
||||
// I've never been happy that the actual individual PART_LIB is left up to
|
||||
// flimsy search path ordering. None-the-less find a part based on that design:
|
||||
if( LIB_PART* part = aLibs->FindLibPart( m_lib_id.GetLibItemName() ) )
|
||||
if( LIB_PART* part = aLibs->FindLibPart( m_lib_id ) )
|
||||
{
|
||||
m_part = part->SharedPtr();
|
||||
return true;
|
||||
|
@ -1199,7 +1199,7 @@ bool SCH_COMPONENT::Load( LINE_READER& aLine, wxString& aErrorMsg )
|
|||
|
||||
if( partname != NULL_STRING )
|
||||
{
|
||||
m_lib_id.SetLibItemName( partname );
|
||||
m_lib_id.SetLibItemName( partname, false );
|
||||
|
||||
if( !newfmt )
|
||||
GetField( VALUE )->SetText( partname );
|
||||
|
|
|
@ -1306,7 +1306,7 @@ SCH_COMPONENT* SCH_LEGACY_PLUGIN::loadComponent( FILE_LINE_READER& aReader )
|
|||
parseUnquotedString( libName, aReader, line, &line );
|
||||
libName.Replace( "~", " " );
|
||||
|
||||
LIB_ID libId( libName );
|
||||
LIB_ID libId( wxEmptyString, libName );
|
||||
|
||||
component->SetLibId( libId );
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ static void DisplayCmpDocAndKeywords( wxString& aName, void* aData )
|
|||
|
||||
wxASSERT( libs );
|
||||
|
||||
LIB_ALIAS* part = libs->FindLibraryAlias( aName );
|
||||
LIB_ID id( wxEmptyString, aName );
|
||||
LIB_ALIAS* part = libs->FindLibraryAlias( id );
|
||||
|
||||
if( !part )
|
||||
return;
|
||||
|
|
|
@ -114,7 +114,8 @@ void LIB_VIEW_FRAME::onSelectPreviousSymbol( wxCommandEvent& aEvent )
|
|||
|
||||
void LIB_VIEW_FRAME::onViewSymbolDocument( wxCommandEvent& aEvent )
|
||||
{
|
||||
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName );
|
||||
LIB_ID id( wxEmptyString, m_entryName );
|
||||
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( id, m_libraryName );
|
||||
|
||||
if( entry && !entry->GetDocFileName().IsEmpty() )
|
||||
{
|
||||
|
@ -185,7 +186,8 @@ void LIB_VIEW_FRAME::DisplayLibInfos()
|
|||
|
||||
void LIB_VIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
||||
{
|
||||
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( m_entryName, m_libraryName );
|
||||
LIB_ID id( wxEmptyString, m_entryName );
|
||||
LIB_ALIAS* entry = Prj().SchLibs()->FindLibraryAlias( id, m_libraryName );
|
||||
|
||||
if( !entry )
|
||||
return;
|
||||
|
|
|
@ -74,6 +74,19 @@ public:
|
|||
|
||||
LIB_ID( const wxString& aId ) throw( PARSE_ERROR );
|
||||
|
||||
/**
|
||||
* This LIB_ID ctor is a special version which ignores the parsing due to symbol
|
||||
* names allowing '/' as a valid character. This was causing the symbol names to
|
||||
* be truncated at the first occurrence of '/' in the symbol name.
|
||||
*
|
||||
* @param aLibName is the library nickname used to look up the library item in the #LIB_TABLE.
|
||||
* @param aLibItemName is the name of the library item which is not parsed by the standard
|
||||
* LIB_ID::Parse() function.
|
||||
* @param aRevision is the revision of the library item.
|
||||
*/
|
||||
LIB_ID( const wxString& aLibName, const wxString& aLibItemName,
|
||||
const wxString& aRevision = wxEmptyString );
|
||||
|
||||
/**
|
||||
* Function Parse
|
||||
*
|
||||
|
@ -124,7 +137,7 @@ public:
|
|||
* into the parameter at which an error was detected, usually because it
|
||||
* contained '/'.
|
||||
*/
|
||||
int SetLibItemName( const UTF8& aLibItemName );
|
||||
int SetLibItemName( const UTF8& aLibItemName, bool aTestForRev = true );
|
||||
|
||||
int SetRevision( const UTF8& aRevision );
|
||||
|
||||
|
|
Loading…
Reference in New Issue