Fix null dereference in 2D intersection view synchronization

In Rim2dIntersectionViewCollection::syncFromExistingIntersections the
branch reusing an existing view dereferenced the RimGridView ancestor
without a null check, while the branch creating a new view already
guarded it with "if ( view )".

Intersections created without a RimGridView ancestor (for example via
the gRPC/Python API on a detached intersection collection) have a null
ancestor, causing a crash on the cellVisibilityChanged disconnect/connect
calls. Guard these calls with the same null check used in the new-view
branch and always push the existing view back into the collection.
This commit is contained in:
Magne Sjaastad authored and Kristian Bendiksen committed 2026-06-10 08:47:02 +02:00
1 parent 22f9053401
commit 221305b741
1 file changed
+5 -2
@@ -108,9 +108,12 @@ void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpda
}
else
{
view->cellVisibilityChanged.disconnect( it->second );
if ( view )
{
view->cellVisibilityChanged.disconnect( it->second );
view->cellVisibilityChanged.connect( it->second, &Rim2dIntersectionView::onCellVisibilityChanged );
}
m_intersectionViews.push_back( it->second );
view->cellVisibilityChanged.connect( it->second, &Rim2dIntersectionView::onCellVisibilityChanged );
}
}