From 283770fc4505b47f1f980d295490c0360e9b5dc7 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 13 Mar 2023 16:06:24 -0700 Subject: [PATCH] Check for dirtied items in the cluster When drawing the ratsnest, we need to be careful to avoid accessing CONN_ITEMs that have been changed by the underlying model. Checking for dirty items instead of valid items will prevent us looking at data that are out of date Fixes https://gitlab.com/kicad/code/kicad/issues/14265 --- pcbnew/board.cpp | 2 +- pcbnew/connectivity/connectivity_items.cpp | 6 ++++++ pcbnew/connectivity/connectivity_items.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 1569f86a98..96e15c1cd2 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -292,7 +292,7 @@ void BOARD::UpdateRatsnestExclusions() [&]( CN_EDGE& aEdge ) { if( aEdge.GetSourceNode() && aEdge.GetTargetNode() - && aEdge.GetSourceNode()->Valid() && aEdge.GetTargetNode()->Valid() ) + && !aEdge.GetSourceNode()->Dirty() && !aEdge.GetTargetNode()->Dirty() ) { std::pair ids = { aEdge.GetSourceNode()->Parent()->m_Uuid, aEdge.GetTargetNode()->Parent()->m_Uuid }; diff --git a/pcbnew/connectivity/connectivity_items.cpp b/pcbnew/connectivity/connectivity_items.cpp index 3b36c13be4..1803fb928e 100644 --- a/pcbnew/connectivity/connectivity_items.cpp +++ b/pcbnew/connectivity/connectivity_items.cpp @@ -275,6 +275,12 @@ bool CN_ANCHOR::Valid() const } +bool CN_ANCHOR::Dirty() const +{ + return !Valid() || m_item->Dirty(); +} + + bool CN_ANCHOR::IsDangling() const { int accuracy = 0; diff --git a/pcbnew/connectivity/connectivity_items.h b/pcbnew/connectivity/connectivity_items.h index b331dbf215..b52b33b735 100644 --- a/pcbnew/connectivity/connectivity_items.h +++ b/pcbnew/connectivity/connectivity_items.h @@ -72,6 +72,8 @@ public: bool Valid() const; + bool Dirty() const; + CN_ITEM* Item() const { return m_item;