From 21d9a3d4bd62892638f00fce74357a53478aa84b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 2 Jul 2019 17:15:26 +0200 Subject: [PATCH] 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. --- eeschema/libedit/lib_manager.cpp | 28 +++++++------------ .../symbol_tree_synchronizing_adapter.cpp | 6 +++- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/eeschema/libedit/lib_manager.cpp b/eeschema/libedit/lib_manager.cpp index dbe41270f5..5e84c68f66 100644 --- a/eeschema/libedit/lib_manager.cpp +++ b/eeschema/libedit/lib_manager.cpp @@ -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_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_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; diff --git a/eeschema/symbol_tree_synchronizing_adapter.cpp b/eeschema/symbol_tree_synchronizing_adapter.cpp index e1c1778fca..2c4f640afe 100644 --- a/eeschema/symbol_tree_synchronizing_adapter.cpp +++ b/eeschema/symbol_tree_synchronizing_adapter.cpp @@ -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();