From c7e4875505f08b50efe5db6acd621c0a89a5afb0 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 26 Apr 2025 10:37:23 +0200 Subject: [PATCH] Gerbview: fix a few issues when loading zip files Fixes https://gitlab.com/kicad/code/kicad/-/issues/20779 --- gerbview/files.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gerbview/files.cpp b/gerbview/files.cpp index e69b10c9f9..f000955ca6 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -423,13 +423,12 @@ bool GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles( const wxString& aPath, } - - bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aReporter ) { bool foundX2Gerbers = false; wxString msg; int firstLoadedLayer = NO_AVAILABLE_LAYERS; + LSET visibility = GetVisibleLayers(); // Extract the path of aFullFileName. We use it to store temporary files wxFileName fn( aFullFileName ); @@ -494,7 +493,7 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR enum GERBER_ORDER_ENUM order; GERBER_FILE_IMAGE_LIST::GetGerberLayerFromFilename( fname, order, matchedExt ); - int layer = GetActiveLayer(); + int layer = getNextAvailableLayer(); if( layer == NO_AVAILABLE_LAYERS ) { @@ -516,6 +515,8 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR continue; } + SetActiveLayer( layer, false ); + // Create the unzipped temporary file: { wxFFileOutputStream temporary_ofile( unzipped_tempfile ); @@ -599,6 +600,7 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR else { GERBER_FILE_IMAGE* gerber_image = GetGbrImage( layer ); + visibility[ layer ] = true; if( gerber_image ) { @@ -617,6 +619,8 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR else SortLayersByFileExtension(); + SetVisibleLayers( visibility ); + // Select the first layer loaded so we don't show another layer on top after if( firstLoadedLayer != NO_AVAILABLE_LAYERS ) SetActiveLayer( firstLoadedLayer, true );