From 30da2b31ea1b13f180cea294a045fb039a48bd3b Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 9 Dec 2019 14:47:29 -0500 Subject: [PATCH] Eeschema: fix multiple symbol rescue bug caused by commit 54f066fe. Use the root symbol when comparing against the cached symbol when checking to see if a symbol changed. When the original symbol is a derived symbol, the test will always fail. Force a symbol link refresh on a rescue to prevent stale links from crashing the connection graph refresh when running the project rescue on demand. Force a symbol link refresh on project load to prevent stale links from symbol link changes from crashing the connection graph when the project rescue in invoked. Fixes kicad/code/kicad#3645 --- eeschema/files-io.cpp | 4 +++- eeschema/project_rescue.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index b0cb8a1fd1..2ab60d24e4 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -388,7 +388,9 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in RescueSymbolLibTableProject( false ); } - schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets. + schematic.UpdateSymbolLinks( true ); // Update all symbol library links for all sheets. + g_ConnectionGraph->Reset(); + RecalculateConnections( GLOBAL_CLEANUP ); SetScreen( g_CurrentSheet->LastScreen() ); // Migrate conflicting bus definitions diff --git a/eeschema/project_rescue.cpp b/eeschema/project_rescue.cpp index 7a8ba0e045..5a6205ba73 100644 --- a/eeschema/project_rescue.cpp +++ b/eeschema/project_rescue.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -373,14 +374,35 @@ void RESCUE_SYMBOL_LIB_TABLE_CANDIDATE::FindRescues( // A new part name is found (a new group starts here). // Search the symbol names candidates only once for this group: old_part_id = part_id; + + // Get the library symbol from the cache library. It will be a flattened + // symbol by default (no inheritance). cache_match = find_component( part_id.Format().wx_str(), aRescuer.GetPrj()->SchLibs(), true ); + // Get the library symbol from the symbol library table. lib_match = SchGetLibPart( part_id, aRescuer.GetPrj()->SchSymbolLibTable() ); if( !cache_match && !lib_match ) continue; + PART_SPTR lib_match_parent; + + // If it's a derive symbol, use the parent symbol to perform the pin test. + if( lib_match && lib_match->IsAlias() ) + { + lib_match_parent = lib_match->GetParent().lock(); + + if( !lib_match_parent ) + { + lib_match = nullptr; + } + else + { + lib_match = lib_match_parent.get(); + } + } + // Test whether there is a conflict or if the symbol can only be found in the cache. if( LIB_ID::HasIllegalChars( part_id.GetLibItemName(), LIB_ID::ID_SCH ) == -1 ) { @@ -535,6 +557,15 @@ bool SCH_EDIT_FRAME::rescueProject( RESCUER& aRescuer, bool aRunningOnDemand ) if( viewer ) viewer->ReCreateListLib(); + if( aRunningOnDemand ) + { + SCH_SCREENS schematic; + + schematic.UpdateSymbolLinks( true ); + g_ConnectionGraph->Reset(); + RecalculateConnections( GLOBAL_CLEANUP ); + } + GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 ); SyncView(); GetCanvas()->Refresh();