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.
(cherry picked from commit 887c8d3bdf)
This commit is contained in:
@@ -1706,6 +1706,7 @@ void TaskSketcherConstraints::slotConstraintsChanged()
|
||||
assert(sketchView);
|
||||
|
||||
constraintMap.clear();
|
||||
selectionBuffer.clear();
|
||||
|
||||
// Build up ListView with the constraints
|
||||
const Sketcher::SketchObject* sketch = sketchView->getSketchObject();
|
||||
|
||||
@@ -1873,6 +1873,7 @@ void TaskSketcherElements::slotElementsChanged()
|
||||
|
||||
ui->listWidgetElements->clear();
|
||||
elementMap.clear();
|
||||
selectionBuffer.clear();
|
||||
|
||||
using GeometryState = ElementItem::GeometryState;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user