From 939313088edcf228192854d210040d34cbb666df Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 30 Jun 2022 14:57:23 -0700 Subject: [PATCH] Units are stored in the instance data At the moment, units are stored in the instance data, so when loading the file, all symbols will have bbox for the first unit. After calling `UpdateUnit()`, we need to recache the rtree bounding boxes to get correct hit tests Fixes https://gitlab.com/kicad/code/kicad/issues/11681 --- eeschema/files-io.cpp | 2 ++ eeschema/sch_painter.cpp | 2 ++ eeschema/sch_sheet_path.cpp | 13 ++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index c98d5b9344..b741312444 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -488,6 +488,8 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in SyncView(); GetScreen()->ClearDrawingState(); + TestDanglingEnds(); + UpdateHierarchyNavigator(); UpdateTitle(); m_toolManager->GetTool()->ResetHistory(); diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 68d1730fea..a09e0d5b4b 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -2113,6 +2113,8 @@ void SCH_PAINTER::draw( SCH_SYMBOL* aSymbol, int aLayer ) if( symbolPin->IsDangling() ) tempPin->SetFlags( IS_DANGLING ); + else + tempPin->ClearFlags( IS_DANGLING ); } draw( &tempSymbol, aLayer, false, aSymbol->GetUnit(), aSymbol->GetConvert() ); diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 4a6a53aa41..89393312b5 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -314,13 +314,24 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName ) const void SCH_SHEET_PATH::UpdateAllScreenReferences() const { - for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_SYMBOL_T ) ) + std::vector symbols; + + std::copy_if( LastScreen()->Items().begin(), + LastScreen()->Items().end(), + std::back_inserter( symbols ), + []( SCH_ITEM* aItem ) + { + return ( aItem->Type() == SCH_SYMBOL_T ); + } ); + + for( SCH_ITEM* item : symbols ) { SCH_SYMBOL* symbol = static_cast( item ); symbol->GetField( REFERENCE_FIELD )->SetText( symbol->GetRef( this ) ); symbol->GetField( VALUE_FIELD )->SetText( symbol->GetValue( this, false ) ); symbol->GetField( FOOTPRINT_FIELD )->SetText( symbol->GetFootprint( this, false ) ); symbol->UpdateUnit( symbol->GetUnitSelection( this ) ); + LastScreen()->Update( item ); } }