Eeschema, lib editor: fix a message error when loading a symbol from the schematic editor.

Replace also in lib_manager.cpp some DisplayErrorMessage calls by wxLogMessage calls,
to avoid hanging or crashes, at least on Windows.
wxLogMessage also has the advantage of grouping all messages and displaying them during a idle time.
This commit is contained in:
jean-pierre charras 2019-07-02 17:15:26 +02:00
parent 527d9509d3
commit 21d9a3d4bd
2 changed files with 15 additions and 19 deletions

View File

@ -117,8 +117,8 @@ SYMBOL_LIB_TABLE_ROW* LIB_MANAGER::GetLibrary( const wxString& aLibrary ) const
}
catch( const IO_ERROR& e )
{
DisplayErrorMessage( &m_frame, wxString::Format( _( "Cannot find library \"%s\" in "
"the Symbol Library Table" ), aLibrary ), e.What() );
wxLogMessage( _( "Cannot find library \"%s\" in the Symbol Library Table (%s)" ),
aLibrary, e.What() );
}
return row;
@ -156,8 +156,7 @@ bool LIB_MANAGER::FlushLibrary( const wxString& aLibrary )
}
catch( const IO_ERROR& e )
{
DisplayErrorMessage( &m_frame, wxString::Format( _( "Cannot flush "
"library changes (\"%s\")" ), aLibrary ), e.What() );
wxLogMessage( _( "Cannot flush library changes (\"%s\") (%s)" ), aLibrary, e.What() );
}
// Assume all libraries are successfully saved
@ -312,8 +311,7 @@ wxArrayString LIB_MANAGER::GetAliasNames( const wxString& aLibrary ) const
}
catch( const IO_ERROR& e )
{
DisplayErrorMessage( &m_frame, wxString::Format( _( "Cannot enumerate "
"library \"%s\"" ), aLibrary ), e.What() );
wxLogMessage( _( "Cannot enumerate library \"%s\" (%s)" ), aLibrary, e.What() );
}
}
else
@ -350,8 +348,7 @@ std::list<LIB_ALIAS*> LIB_MANAGER::GetAliases( const wxString& aLibrary ) const
}
catch( const IO_ERROR& e )
{
DisplayErrorMessage( &m_frame, wxString::Format( _( "Cannot load "
"aliases from library \"%s\"" ), aLibrary ), e.What() );
wxLogMessage( _( "Cannot load aliases from library \"%s\" (%s)" ), aLibrary, e.What() );
}
std::copy( aliases.begin(), aliases.end(), std::back_inserter( ret ) );
@ -384,11 +381,8 @@ LIB_PART* LIB_MANAGER::GetBufferedPart( const wxString& aAlias, const wxString&
}
catch( const IO_ERROR& e )
{
wxString msg = wxString::Format( _( "Error loading symbol \"%s\" from library \"%s\"." ),
aAlias,
aLibrary);
DisplayErrorMessage( &m_frame, msg, e.What() );
wxLogMessage( _( "Error loading symbol \"%s\" from library \"%s\". (%s)" ),
aAlias, aLibrary, e.What() );
bufferedPart = nullptr;
}
}
@ -582,8 +576,8 @@ LIB_ALIAS* LIB_MANAGER::GetAlias( const wxString& aAlias, const wxString& aLibra
}
catch( const IO_ERROR& e )
{
DisplayErrorMessage( &m_frame, wxString::Format( _( "Cannot load "
"symbol \"%s\" from library \"%s\"" ), aAlias, aLibrary ), e.What() );
wxLogMessage( _( "Cannot load symbol \"%s\" from library \"%s\" (%s)" ),
aAlias, aLibrary, e.What() );
}
return alias;
@ -729,9 +723,7 @@ std::set<LIB_PART*> LIB_MANAGER::getOriginalParts( const wxString& aLibrary )
}
catch( const IO_ERROR& e )
{
DisplayErrorMessage( &m_frame,
wxString::Format( _( "Cannot enumerate library \"%s\"" ), aLibrary ),
e.What() );
wxLogMessage( _( "Cannot enumerate library \"%s\" (%s)" ), aLibrary, e.What() );
}
return parts;

View File

@ -229,7 +229,11 @@ void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataVie
case 1:
if( node->LibId == m_libMgr->GetCurrentLibId() )
{
auto alias = m_libMgr->GetAlias( node->Name, node->Parent->Name );
LIB_ALIAS* alias = nullptr;
// When the node parent name is empty, the node is a lib name, not a symbol name
if( !node->Parent->Name.IsEmpty() )
alias = m_libMgr->GetAlias( node->Name, node->Parent->Name );
if( alias )
aVariant = alias->GetDescription();