Avoid unmapped layers

ViewGetLayers returns the item layer even if it is invalid.  We filter
this out at the base and skip items that cannot be displayed in the
view.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21368
This commit is contained in:
Seth Hillbrand
2025-07-24 13:39:13 -07:00
parent 322c08d5f0
commit d538f8d848
+9
View File
@@ -312,6 +312,15 @@ void VIEW::Add( VIEW_ITEM* aItem, int aDrawPriority )
aItem->m_viewPrivData->m_cachedIndex = m_allItems->size();
std::vector<int> layers = aItem->ViewGetLayers();
std::erase_if( layers, []( int layer )
{
return layer < 0 || layer >= VIEW_MAX_LAYERS;
} );
if( layers.empty() )
return;
aItem->viewPrivData()->saveLayers( layers );
m_allItems->push_back( aItem );