From c7c1748920827ca2e35dbb71724bb187a3111d60 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <seth@kipro-pcb.com>
Date: Tue, 14 Jan 2025 15:27:00 -0800
Subject: [PATCH] Keep the scoped copy of LSET

Attempting to fix an unknown windows crash

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19488
---
 pcbnew/drc/drc_test_provider_creepage.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pcbnew/drc/drc_test_provider_creepage.cpp b/pcbnew/drc/drc_test_provider_creepage.cpp
index 2e6d3ac129..53b3d6c3d4 100644
--- a/pcbnew/drc/drc_test_provider_creepage.cpp
+++ b/pcbnew/drc/drc_test_provider_creepage.cpp
@@ -374,6 +374,7 @@ int DRC_TEST_PROVIDER_CREEPAGE::testCreepage()
     size_t current = 0;
     size_t total =
             ( netcodes.size() * ( netcodes.size() - 1 ) ) / 2 * m_board->GetCopperLayerCount();
+    LSET layers = m_board->GetLayerSet();
 
     alg::for_all_pairs( netcodes.begin(), netcodes.end(),
                         [&]( int aNet1, int aNet2 )
@@ -381,8 +382,10 @@ int DRC_TEST_PROVIDER_CREEPAGE::testCreepage()
                             if( aNet1 == aNet2 )
                                 return;
 
-                            for( auto it = m_board->GetLayerSet().copper_layers_begin();
-                                      it != m_board->GetLayerSet().copper_layers_end();
+
+
+                            for( auto it = layers.copper_layers_begin();
+                                      it != layers.copper_layers_end();
                                       ++it )
                             {
                                 PCB_LAYER_ID layer = *it;