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

From 0b53a33034ba81b829d4ffe3169257899c2c856c 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/2] 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 7caf68ff60..170174b453 100644
--- a/pcbnew/connectivity/connectivity_data.cpp
+++ b/pcbnew/connectivity/connectivity_data.cpp
@@ -717,23 +717,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