Repository: FreeCAD/FreeCAD
File: src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp (C++)

Code before:
        return;
    }

    QSignalBlocker block(ui->listWidgetConstraints);

    QItemSelection selectionObj;
    for (const auto& update : selectionBuffer) {
        // NOTE: We trust the buffer has valid pointers (lifetime matches widget)
        if (update.select) {
            QModelIndex idx = ui->listWidgetConstraints->model()->index(ui->listWidgetConstraints->row(update.item), 0);
            selectionObj.select(idx, idx);
        } else {
            update.item->setSelected(false);
        }
    }
    ui->listWidgetConstraints->selectionModel()->select(selectionObj, QItemSelectionModel::Select);

    // Scroll only if single item selected
    if (selectionBuffer.size() == 1 && selectionBuffer[0].select) {
        SketcherGui::scrollTo(ui->listWidgetConstraints, ui->listWidgetConstraints->row(selectionBuffer[0].item), true);
    }

    if (specialFilterMode == SpecialFilterType::Selected) {
        updateSelectionFilter();
        bool block =
            this->blockSelection(true);// avoid to be notified by itself
        updateList();
        this->blockSelection(block);
    }

    selectionBuffer.clear();
}

void TaskSketcherConstraints::deferredUpdateList()
{
    updateAssociatedConstraintsFilter();
    updateList();
    updateListPending = false;
}

void TaskSketcherConstraints::OnChange(Base::Subject<const char*>& rCaller, const char* rcReason)
{
    Q_UNUSED(rCaller);
    int actNum = -1;
    auto hGrp = App::GetApplication().GetParameterGroupByPath(
        "User parameter:BaseApp/Preferences/Mod/Sketcher");
    if (strcmp(rcReason, "AutoRemoveRedundants") == 0) {
        actNum = 1;
    }
    else if (strcmp(rcReason, "VisualisationTrackingFilter") == 0) {
        actNum = 2;

Review comment (suggestion):
```suggestion
        // avoid to be notified by itself
        bool block = this->blockSelection(true);
```

Code after:
        return;
    }

    QSignalBlocker block(ui->listWidgetConstraints);

    QItemSelection selectionObj;
    for (const auto& update : selectionBuffer) {
        // NOTE: We trust the buffer has valid pointers (lifetime matches widget)
        if (update.select) {
            QModelIndex idx = ui->listWidgetConstraints->model()->index(ui->listWidgetConstraints->row(update.item), 0);
            selectionObj.select(idx, idx);
        } else {
            update.item->setSelected(false);
        }
    }
    ui->listWidgetConstraints->selectionModel()->select(selectionObj, QItemSelectionModel::Select);

    // Scroll only if single item selected
    if (selectionBuffer.size() == 1 && selectionBuffer[0].select) {
        SketcherGui::scrollTo(ui->listWidgetConstraints, ui->listWidgetConstraints->row(selectionBuffer[0].item), true);
    }

    if (specialFilterMode == SpecialFilterType::Selected) {
        updateSelectionFilter();
        // avoid to be notified by itself
        bool block = this->blockSelection(true);
        updateList();
        this->blockSelection(block);
    }

    selectionBuffer.clear();
}

void TaskSketcherConstraints::deferredUpdateList()
{
    updateAssociatedConstraintsFilter();
    updateList();
    updateListPending = false;
}

void TaskSketcherConstraints::OnChange(Base::Subject<const char*>& rCaller, const char* rcReason)
{
    Q_UNUSED(rCaller);
    int actNum = -1;
    auto hGrp = App::GetApplication().GetParameterGroupByPath(
        "User parameter:BaseApp/Preferences/Mod/Sketcher");
    if (strcmp(rcReason, "AutoRemoveRedundants") == 0) {
        actNum = 1;
    }
    else if (strcmp(rcReason, "VisualisationTrackingFilter") == 0) {
        actNum = 2;