From 6c97a40b8c6338f9a080393be69313b9699f12f3 Mon Sep 17 00:00:00 2001
From: Jeff Young <jeff@rokeby.ie>
Date: Mon, 17 Mar 2025 11:04:27 +0000
Subject: [PATCH] Attempt to fix lack of initialisation on GTK/MSW.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20050
---
 pcbnew/widgets/pcb_net_inspector_panel.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/pcbnew/widgets/pcb_net_inspector_panel.cpp b/pcbnew/widgets/pcb_net_inspector_panel.cpp
index add2f863f9..85e068f626 100644
--- a/pcbnew/widgets/pcb_net_inspector_panel.cpp
+++ b/pcbnew/widgets/pcb_net_inspector_panel.cpp
@@ -1947,9 +1947,17 @@ void PCB_NET_INSPECTOR_PANEL::onUnitsChanged( wxCommandEvent& event )
 
 void PCB_NET_INSPECTOR_PANEL::SaveSettings()
 {
-    // Don't save settings if a board has not yet been loaded - events fire while we set up the
-    // panel which overwrites the settings we haven't yet loaded
-    if( !m_board_loaded || m_board_loading )
+    // Don't save settings if a board has not yet been loaded or the panel hasn't been displayed.
+    // Events fire while we set up the panel which overwrite the settings we haven't yet loaded.
+    bool displayed = false;
+
+    for( unsigned int ii = 0; ii < m_data_model->columnCount() && !displayed; ++ii )
+    {
+        if( m_netsList->GetColumn( ii )->GetWidth() > 0 )
+            displayed = true;
+    }
+
+    if( !displayed || !m_board_loaded || m_board_loading )
         return;
 
     PROJECT_LOCAL_SETTINGS& localSettings = Pgm().GetSettingsManager().Prj().GetLocalSettings();