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

(cherry picked from commit d538f8d848798f3905ab9664df7e28cf79a1271b)
This commit is contained in:
Seth Hillbrand 2025-07-24 13:39:13 -07:00
parent e7eedc7567
commit 21ed7a0641

View File

@ -313,6 +313,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 );