File fix-for-issue-17429-backported-from-master.patch of Package kicad.8

From a171246cc790aa4ecfd11740b1b80467f3e47929 Mon Sep 17 00:00:00 2001
From: Adam Feuer <adam@adamfeuer.com>
Date: Tue, 14 Jan 2025 08:39:51 -0800
Subject: [PATCH 1/3] fix for issue 17429 - backported from master

- issue: https://gitlab.com/kicad/code/kicad/-/issues/17429
- fix makes RunOnUnconnectedEdges sort the unnconnected edges before
  running the passed in function on them
- stable sort order keeps the algorith from having non-deterministic
  runs
---
 pcbnew/connectivity/connectivity_data.cpp | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/pcbnew/connectivity/connectivity_data.cpp b/pcbnew/connectivity/connectivity_data.cpp
index 8a0b416e02..dcdffaa10a 100644
--- a/pcbnew/connectivity/connectivity_data.cpp
+++ b/pcbnew/connectivity/connectivity_data.cpp
@@ -703,23 +703,37 @@ unsigned int CONNECTIVITY_DATA::GetPadCount( int aNet ) const
     return n;
 }
 
+void sortEdgesOnSerializationForStableOrdering( std::vector<CN_EDGE>& edges )
+{
+    std::sort(edges.begin(), edges.end(),
+              [](const CN_EDGE& a, const CN_EDGE& b)
+              {
+                  return a.SerializeToString() < b.SerializeToString();
+              });
+}
 
 void CONNECTIVITY_DATA::RunOnUnconnectedEdges( std::function<bool( CN_EDGE& )> aFunc )
 {
+    std::vector<CN_EDGE> edges;
+
     for( RN_NET* rnNet : m_nets )
     {
         if( rnNet )
         {
             for( CN_EDGE& edge : rnNet->GetEdges() )
             {
-                if( !aFunc( edge ) )
-                    return;
+                edges.push_back( edge );
             }
         }
     }
+    sortEdgesOnSerializationForStableOrdering( edges );
+    for( CN_EDGE& edge : edges )
+    {
+        if( !aFunc( edge ) )
+            return;
+    }
 }
 
-
 static int getMinDist( BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aPoint )
 {
     switch( aItem->Type() )
-- 
2.47.1

openSUSE Build Service is sponsored by