Commit b338dfdc authored by charras's avatar charras

Fixed bug 2962142 (Eeschema: Crash SaveEEFile on demo)

parent d438cf68
...@@ -229,14 +229,12 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias ) ...@@ -229,14 +229,12 @@ bool CMP_LIBRARY::AddAlias( LIB_ALIAS* aAlias )
*/ */
LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
{ {
wxASSERT( aComponent != NULL ); if( aComponent == NULL )
return NULL;
LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aComponent, this ); LIB_COMPONENT* newCmp = new LIB_COMPONENT( *aComponent, this );
newCmp->ClearAliasDataDoc(); // Remove data used only in edition newCmp->ClearAliasDataDoc(); // Remove data used only in edition
if( newCmp == NULL )
return NULL;
// Conflict detection: See if already existing aliases exist, // Conflict detection: See if already existing aliases exist,
// and if yes, ask user for continue or abort // and if yes, ask user for continue or abort
// Special case: if the library is the library cache of the project, // Special case: if the library is the library cache of the project,
...@@ -252,13 +250,15 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -252,13 +250,15 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
if( alias == NULL ) if( alias == NULL )
continue; continue;
LIB_COMPONENT* cparent = alias->GetComponent();
if( alias->GetComponent()->GetName().CmpNoCase( newCmp->GetName() ) != 0 ) if( cparent == NULL || // Lib error, should not occurs
( cparent->GetName().CmpNoCase( newCmp->GetName() ) != 0 ) )
{ {
wxString msg1; wxString msg1;
msg1.Printf( _("alias <%s> already exists and has root name<%s>"), msg1.Printf( _("alias <%s> already exists and has root name<%s>"),
GetChars( alias->GetName() ), GetChars( alias->GetName() ),
GetChars( alias->GetComponent()->GetName() ) ); GetChars( cparent ? cparent->GetName() : _("unknown") ) );
msg << msg1 << wxT("\n"); msg << msg1 << wxT("\n");
conflict_count++; conflict_count++;
} }
...@@ -292,12 +292,18 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent ) ...@@ -292,12 +292,18 @@ LIB_COMPONENT* CMP_LIBRARY::AddComponent( LIB_COMPONENT* aComponent )
alias = new LIB_ALIAS( aliasname, newCmp ); alias = new LIB_ALIAS( aliasname, newCmp );
entries.push_back( alias ); entries.push_back( alias );
} }
else if( alias->GetComponent()->GetName().CmpNoCase( newCmp->GetName() ) != 0 ) else
{ {
// Remove alias from library and alias list of its root component LIB_COMPONENT* cparent = alias->GetComponent();
RemoveEntry( alias );
alias = new LIB_ALIAS( aliasname, newCmp ); if( cparent == NULL || // Lib error, should not occurs
entries.push_back( alias ); ( cparent->GetName().CmpNoCase( newCmp->GetName() ) != 0) )
{
// Remove alias from library and alias list of its root component
RemoveEntry( alias );
alias = new LIB_ALIAS( aliasname, newCmp );
entries.push_back( alias );
}
} }
// Update alias data: // Update alias data:
alias->SetDescription( aComponent->GetAliasDataDoc( aliasname ) ); alias->SetDescription( aComponent->GetAliasDataDoc( aliasname ) );
......
...@@ -43,10 +43,14 @@ bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName ) ...@@ -43,10 +43,14 @@ bool LibArchive( wxWindow* frame, const wxString& ArchFullFileName )
continue; continue;
SCH_COMPONENT* component = (SCH_COMPONENT*) SchItem; SCH_COMPONENT* component = (SCH_COMPONENT*) SchItem;
Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName ); // If not already saved in the new cache, put it:
if( libCache->FindEntry( component->m_ChipName) == NULL )
{
Entry = CMP_LIBRARY::FindLibraryComponent( component->m_ChipName );
if( Entry ) // if NULL : component not found if( Entry ) // if NULL : component not found, cannot be stored
libCache->AddComponent( Entry ); libCache->AddComponent( Entry );
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment