Fix highlighting complex connections from subsheets

Sheet() can't be used for local sheet recall in these cases

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9403
This commit is contained in:
Jon Evans 2021-10-25 22:14:48 -04:00
parent 1f7fd436a2
commit 8e5cbc5cf0
3 changed files with 16 additions and 2 deletions

View File

@ -63,6 +63,7 @@
SCH_CONNECTION::SCH_CONNECTION( SCH_ITEM* aParent, SCH_SHEET_PATH aPath ) :
m_sheet( aPath ),
m_local_sheet( aPath ),
m_parent( aParent ),
m_driver( nullptr ),
m_graph( nullptr )
@ -73,6 +74,7 @@ SCH_CONNECTION::SCH_CONNECTION( SCH_ITEM* aParent, SCH_SHEET_PATH aPath ) :
SCH_CONNECTION::SCH_CONNECTION( CONNECTION_GRAPH* aGraph ) :
m_sheet( SCH_SHEET_PATH() ),
m_local_sheet( SCH_SHEET_PATH() ),
m_parent( nullptr ),
m_driver( nullptr ),
m_graph( aGraph )
@ -110,6 +112,7 @@ void SCH_CONNECTION::SetDriver( SCH_ITEM* aItem )
void SCH_CONNECTION::SetSheet( SCH_SHEET_PATH aSheet )
{
m_sheet = aSheet;
m_local_sheet = aSheet;
recacheName();
@ -230,6 +233,7 @@ void SCH_CONNECTION::Clone( const SCH_CONNECTION& aOther )
// Note: m_lastDriver is not cloned as it needs to be the last driver of *this* connection
m_driver = aOther.Driver();
m_sheet = aOther.Sheet();
// Note: m_local_sheet is not cloned
m_name = aOther.m_name;
// Note: m_local_name is not cloned if not set yet
if( m_local_name.IsEmpty() )

View File

@ -109,6 +109,8 @@ public:
SCH_SHEET_PATH Sheet() const { return m_sheet; }
void SetSheet( SCH_SHEET_PATH aSheet );
SCH_SHEET_PATH LocalSheet() const { return m_local_sheet; }
/**
* Checks if the SCH_ITEM this connection is attached to can drive connections
* Drivers can be labels, sheet pins, or symbol pins.
@ -240,6 +242,14 @@ private:
SCH_SHEET_PATH m_sheet; ///< The hierarchical sheet this connection is on
/**
* When a connection is overridden by one on a different hierarchical sheet, it will be cloned
* and m_sheet will point to the parent sheet. This member stores the original sheet so that it
* can be used for applications such as net highlighting to retrieve the sheet of the parent
* item from the highlighted connection.
*/
SCH_SHEET_PATH m_local_sheet;
SCH_ITEM* m_parent; ///< The SCH_ITEM this connection is owned by
void* m_lastDriver; ///< WEAK POINTER (there is no guarantee it is still allocated)

View File

@ -1285,7 +1285,7 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags )
SCH_SHEET_PATH highlightPath;
if( highlight )
highlightPath = highlight->Sheet();
highlightPath = highlight->LocalSheet();
SCHEMATIC_SETTINGS& settings = Schematic().Settings();
SCH_SHEET_LIST list = Schematic().GetSheets();