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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user