Gerbview: fix a few issues when loading zip files

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20779
This commit is contained in:
jean-pierre charras 2025-04-26 10:37:23 +02:00
parent 7309f7049f
commit c7e4875505

View File

@ -423,13 +423,12 @@ bool GERBVIEW_FRAME::LoadListOfGerberAndDrillFiles( const wxString& aPath,
} }
bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aReporter ) bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aReporter )
{ {
bool foundX2Gerbers = false; bool foundX2Gerbers = false;
wxString msg; wxString msg;
int firstLoadedLayer = NO_AVAILABLE_LAYERS; int firstLoadedLayer = NO_AVAILABLE_LAYERS;
LSET visibility = GetVisibleLayers();
// Extract the path of aFullFileName. We use it to store temporary files // Extract the path of aFullFileName. We use it to store temporary files
wxFileName fn( aFullFileName ); wxFileName fn( aFullFileName );
@ -494,7 +493,7 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR
enum GERBER_ORDER_ENUM order; enum GERBER_ORDER_ENUM order;
GERBER_FILE_IMAGE_LIST::GetGerberLayerFromFilename( fname, order, matchedExt ); GERBER_FILE_IMAGE_LIST::GetGerberLayerFromFilename( fname, order, matchedExt );
int layer = GetActiveLayer(); int layer = getNextAvailableLayer();
if( layer == NO_AVAILABLE_LAYERS ) if( layer == NO_AVAILABLE_LAYERS )
{ {
@ -516,6 +515,8 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR
continue; continue;
} }
SetActiveLayer( layer, false );
// Create the unzipped temporary file: // Create the unzipped temporary file:
{ {
wxFFileOutputStream temporary_ofile( unzipped_tempfile ); wxFFileOutputStream temporary_ofile( unzipped_tempfile );
@ -599,6 +600,7 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR
else else
{ {
GERBER_FILE_IMAGE* gerber_image = GetGbrImage( layer ); GERBER_FILE_IMAGE* gerber_image = GetGbrImage( layer );
visibility[ layer ] = true;
if( gerber_image ) if( gerber_image )
{ {
@ -617,6 +619,8 @@ bool GERBVIEW_FRAME::unarchiveFiles( const wxString& aFullFileName, REPORTER* aR
else else
SortLayersByFileExtension(); SortLayersByFileExtension();
SetVisibleLayers( visibility );
// Select the first layer loaded so we don't show another layer on top after // Select the first layer loaded so we don't show another layer on top after
if( firstLoadedLayer != NO_AVAILABLE_LAYERS ) if( firstLoadedLayer != NO_AVAILABLE_LAYERS )
SetActiveLayer( firstLoadedLayer, true ); SetActiveLayer( firstLoadedLayer, true );