Skip to content

Commit 1da32f9

Browse files
authored
Fix notifications on clear surface widget (#3709)
1 parent 29caf34 commit 1da32f9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

source/MRViewer/MRSurfaceContoursWidget.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ bool SurfaceContoursWidget::removePoint( const std::shared_ptr<VisualObject>& ob
335335
}
336336
surfacePointWidgetCache_.erase( contour[pickedIndex]->getPickSphere().get() );
337337
contour.erase( contour.begin() + pickedIndex );
338-
assert( contour.size() > pickedIndex );
338+
assert( contour.size() >= pickedIndex );
339339
activeIndex_ = pickedIndex;
340340
activeObject_ = obj;
341341
highlightLastPoint( obj );
@@ -557,12 +557,19 @@ void SurfaceContoursWidget::clear( bool writeHistory )
557557
if ( params.writeHistory && writeHistory )
558558
AppendHistory<SurfaceContoursWidgetClearAction>( "Clear points" + params.historyNameSuffix, *this );
559559

560-
while ( !pickedPoints_.empty() )
560+
for ( auto& [obj, contour] : pickedPoints_ )
561561
{
562-
auto obj = pickedPoints_.begin()->first;
563-
pickedPoints_.erase( pickedPoints_.begin() );
564-
onPointRemove_( obj );
562+
for ( int pickedIndex = int( contour.size() ) - 1; pickedIndex >= 0; --pickedIndex )
563+
{
564+
surfacePointWidgetCache_.erase( contour[pickedIndex]->getPickSphere().get() );
565+
contour.erase( contour.begin() + pickedIndex );
566+
assert( contour.size() >= pickedIndex );
567+
activeIndex_ = pickedIndex;
568+
activeObject_ = obj;
569+
onPointRemove_( obj );
570+
}
565571
}
572+
pickedPoints_.clear();
566573
surfacePointWidgetCache_.clear();
567574
surfaceConnectionHolders_.clear();
568575
activeIndex_ = 0;

0 commit comments

Comments
 (0)