From f047b66cb86f27fc7b6b26a8efcacda7feefbc4f Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 8 Feb 2025 20:27:26 -0500 Subject: [PATCH] Guard against multi-threaded access to connectivity rebuild Fixes https://gitlab.com/kicad/code/kicad/-/issues/19884 --- pcbnew/connectivity/connectivity_algo.cpp | 1 + pcbnew/connectivity/connectivity_algo.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/pcbnew/connectivity/connectivity_algo.cpp b/pcbnew/connectivity/connectivity_algo.cpp index f5dae8b5d5..a96e9ff5e5 100644 --- a/pcbnew/connectivity/connectivity_algo.cpp +++ b/pcbnew/connectivity/connectivity_algo.cpp @@ -228,6 +228,7 @@ void CN_CONNECTIVITY_ALGO::RemoveInvalidRefs() void CN_CONNECTIVITY_ALGO::searchConnections() { + std::lock_guard lock( m_mutex ); #ifdef PROFILE PROF_TIMER garbage_collection( "garbage-collection" ); #endif diff --git a/pcbnew/connectivity/connectivity_algo.h b/pcbnew/connectivity/connectivity_algo.h index 641273edde..9954f715d7 100644 --- a/pcbnew/connectivity/connectivity_algo.h +++ b/pcbnew/connectivity/connectivity_algo.h @@ -298,6 +298,8 @@ private: bool m_isLocal; std::shared_ptr m_globalConnectivityData; + std::mutex m_mutex; + PROGRESS_REPORTER* m_progressReporter = nullptr; };