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:
@@ -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();
|
||||
|
||||
@@ -1875,6 +1875,7 @@ void TaskSketcherElements::slotElementsChanged()
|
||||
|
||||
ui->listWidgetElements->clear();
|
||||
elementMap.clear();
|
||||
selectionBuffer.clear();
|
||||
|
||||
using GeometryState = ElementItem::GeometryState;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user