Sketcher: Fix crash when applying constraints during selection batching

Currently, the selection batching optimization introduced in #26663
stores ElementItem/ConstraintItem pointers in a buffer to be processed
on the next event loop cycle via `QTimer::singleShot`.

When a constraint is applied,
`slotElementsChanged()/slotConstraintsChanged()`
rebuilds the list widget, destroying all items. However, the selection
buffer was not cleared, leaving dangling pointers. When
`processSelectionBuffer()`
executed, it attempted to call `QListWidget::row()` on deleted items,
causing a segmentation fault.

So, this patch fixes it by clearing `selectionBuffer` when the list is
rebuilt, since the buffered pointers are invalidated anyway.
This commit is contained in:
tetektoza
2026-01-07 20:59:02 +01:00
committed by Chris Hennes
parent cc920d70c3
commit d397254275
2 changed files with 2 additions and 0 deletions

View File

@@ -1708,6 +1708,7 @@ void TaskSketcherConstraints::slotConstraintsChanged()
assert(sketchView);
constraintMap.clear();
selectionBuffer.clear();
// Build up ListView with the constraints
const Sketcher::SketchObject* sketch = sketchView->getSketchObject();

View File

@@ -1875,6 +1875,7 @@ void TaskSketcherElements::slotElementsChanged()
ui->listWidgetElements->clear();
elementMap.clear();
selectionBuffer.clear();
using GeometryState = ElementItem::GeometryState;