mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-15 02:33:15 +02:00
More safety against corrupted visibility settings
(cherry picked from commit 1205464472f5d9da1225e47eea6e1555aec943f0)
This commit is contained in:
parent
9a3ae62b70
commit
ff74d7b24a
@ -73,6 +73,10 @@ PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxStrin
|
|||||||
ret.push_back( VisibilityLayerToString( *vl ) );
|
ret.push_back( VisibilityLayerToString( *vl ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Explicit marker to tell apart a wiped-out array from the user hiding everything
|
||||||
|
if( ret.empty() )
|
||||||
|
ret.push_back( "none" );
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
[&]( const nlohmann::json& aVal )
|
[&]( const nlohmann::json& aVal )
|
||||||
@ -85,6 +89,7 @@ PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxStrin
|
|||||||
|
|
||||||
m_VisibleItems &= ~UserVisbilityLayers();
|
m_VisibleItems &= ~UserVisbilityLayers();
|
||||||
GAL_SET visible;
|
GAL_SET visible;
|
||||||
|
bool none = false;
|
||||||
|
|
||||||
for( const nlohmann::json& entry : aVal )
|
for( const nlohmann::json& entry : aVal )
|
||||||
{
|
{
|
||||||
@ -94,13 +99,20 @@ PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxStrin
|
|||||||
|
|
||||||
if( std::optional<GAL_LAYER_ID> l = RenderLayerFromVisbilityString( vs ) )
|
if( std::optional<GAL_LAYER_ID> l = RenderLayerFromVisbilityString( vs ) )
|
||||||
visible.set( *l );
|
visible.set( *l );
|
||||||
|
else if( vs == "none" )
|
||||||
|
none = true;
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
{
|
{
|
||||||
// Non-integer or out of range entry in the array; ignore
|
// Unknown entry (possibly the settings file was re-saved by an old version
|
||||||
|
// of kicad that used numeric entries, or is a future format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore corrupted state
|
||||||
|
if( !visible.any() && !none )
|
||||||
|
m_VisibleItems |= UserVisbilityLayers();
|
||||||
|
else
|
||||||
m_VisibleItems |= UserVisbilityLayers() & visible;
|
m_VisibleItems |= UserVisbilityLayers() & visible;
|
||||||
},
|
},
|
||||||
{} ) );
|
{} ) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user