Fix load/save of layer presets

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5322
This commit is contained in:
Jon Evans 2020-08-23 11:59:40 -04:00
parent 6eab1ce17d
commit f5a6492f85
2 changed files with 6 additions and 2 deletions

View File

@ -869,7 +869,7 @@ std::vector<GAL_LAYER_ID> GAL_SET::Seq() const
for( size_t i = 0; i < size(); ++i ) for( size_t i = 0; i < size(); ++i )
{ {
if( test( i ) ) if( test( i ) )
ret.push_back( static_cast<GAL_LAYER_ID>( i ) ); ret.push_back( static_cast<GAL_LAYER_ID>( i + GAL_LAYER_ID_START ) );
} }
return ret; return ret;

View File

@ -163,6 +163,8 @@ PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
if( preset.contains( "layers" ) && preset.at( "layers" ).is_array() ) if( preset.contains( "layers" ) && preset.at( "layers" ).is_array() )
{ {
p.layers.reset();
for( const nlohmann::json& layer : preset.at( "layers" ) ) for( const nlohmann::json& layer : preset.at( "layers" ) )
{ {
if( layer.is_number_integer() ) if( layer.is_number_integer() )
@ -178,6 +180,8 @@ PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
if( preset.contains( "renderLayers" ) if( preset.contains( "renderLayers" )
&& preset.at( "renderLayers" ).is_array() ) && preset.at( "renderLayers" ).is_array() )
{ {
p.renderLayers.reset();
for( const nlohmann::json& layer : preset.at( "renderLayers" ) ) for( const nlohmann::json& layer : preset.at( "renderLayers" ) )
{ {
if( layer.is_number_integer() ) if( layer.is_number_integer() )
@ -186,7 +190,7 @@ PROJECT_FILE::PROJECT_FILE( const wxString& aFullPath ) :
if( layerNum >= GAL_LAYER_ID_START if( layerNum >= GAL_LAYER_ID_START
&& layerNum < GAL_LAYER_ID_END ) && layerNum < GAL_LAYER_ID_END )
p.layers.set( layerNum ); p.renderLayers.set( static_cast<GAL_LAYER_ID>( layerNum ) );
} }
} }
} }