diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index a79c88995d..cbedda306b 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -164,23 +164,29 @@ void TaskChamferParameters::onRefDeleted(void) return; } + // get the chamfer object + PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); + App::DocumentObject* base = pcChamfer->Base.getValue(); + // get all chamfer references + std::vector refs = pcChamfer->Base.getSubValues(); + // delete the selection backwards to assure the list index keeps valid for the deletion for (int i = selectedList.count() - 1; i > -1; i--) { - // get the fillet object - PartDesign::Chamfer* pcChamfer = static_cast(DressUpView->getObject()); - App::DocumentObject* base = pcChamfer->Base.getValue(); - // get all fillet references - std::vector refs = pcChamfer->Base.getSubValues(); // the ref index is the same as the listWidgetReferences index // so we can erase using the row number of the element to be deleted int rowNumber = ui->listWidgetReferences->row(selectedList.at(i)); + // erase the reference refs.erase(refs.begin() + rowNumber); setupTransaction(); + // update the object pcChamfer->Base.setValue(base, refs); - ui->listWidgetReferences->model()->removeRow(rowNumber); - pcChamfer->getDocument()->recomputeFeature(pcChamfer); + // remove from the list + ui->listWidgetReferences->model()->removeRow(rowNumber); } + // recompute the feature + pcChamfer->getDocument()->recomputeFeature(pcChamfer); + // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { deleteAction->setEnabled(false); diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index 754534ee75..29aaedeb87 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -238,23 +238,29 @@ void TaskDraftParameters::onRefDeleted(void) return; } + // get the draft object + PartDesign::Draft* pcDraft = static_cast(DressUpView->getObject()); + App::DocumentObject* base = pcDraft->Base.getValue(); + // get all draft references + std::vector refs = pcDraft->Base.getSubValues(); + // delete the selection backwards to assure the list index keeps valid for the deletion for (int i = selectedList.count() - 1; i > -1; i--) { - // get the fillet object - PartDesign::Draft* pcDraft = static_cast(DressUpView->getObject()); - App::DocumentObject* base = pcDraft->Base.getValue(); - // get all fillet references - std::vector refs = pcDraft->Base.getSubValues(); // the ref index is the same as the listWidgetReferences index // so we can erase using the row number of the element to be deleted int rowNumber = ui->listWidgetReferences->row(selectedList.at(i)); + // erase the reference refs.erase(refs.begin() + rowNumber); setupTransaction(); + // update the object pcDraft->Base.setValue(base, refs); + // remove from the list ui->listWidgetReferences->model()->removeRow(rowNumber); - pcDraft->getDocument()->recomputeFeature(pcDraft); } + // recompute the feature + pcDraft->getDocument()->recomputeFeature(pcDraft); + // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { deleteAction->setEnabled(false); diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 0baa4cf162..a434f0c139 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -164,23 +164,29 @@ void TaskFilletParameters::onRefDeleted(void) return; } + // get the fillet object + PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); + App::DocumentObject* base = pcFillet->Base.getValue(); + // get all fillet references + std::vector refs = pcFillet->Base.getSubValues(); + // delete the selection backwards to assure the list index keeps valid for the deletion for (int i = selectedList.count()-1; i > -1; i--) { - // get the fillet object - PartDesign::Fillet* pcFillet = static_cast(DressUpView->getObject()); - App::DocumentObject* base = pcFillet->Base.getValue(); - // get all fillet references - std::vector refs = pcFillet->Base.getSubValues(); // the ref index is the same as the listWidgetReferences index // so we can erase using the row number of the element to be deleted int rowNumber = ui->listWidgetReferences->row(selectedList.at(i)); + // erase the reference refs.erase(refs.begin() + rowNumber); setupTransaction(); + // update the object pcFillet->Base.setValue(base, refs); + // remove from the list ui->listWidgetReferences->model()->removeRow(rowNumber); - pcFillet->getDocument()->recomputeFeature(pcFillet); } + // recompute the feature + pcFillet->getDocument()->recomputeFeature(pcFillet); + // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { deleteAction->setEnabled(false); diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 1cdf481144..7991cd63e1 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -186,23 +186,29 @@ void TaskThicknessParameters::onRefDeleted(void) return; } + // get the thickness object + PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); + App::DocumentObject* base = pcThickness->Base.getValue(); + // get all thickness references + std::vector refs = pcThickness->Base.getSubValues(); + // delete the selection backwards to assure the list index keeps valid for the deletion for (int i = selectedList.count() - 1; i > -1; i--) { - // get the fillet object - PartDesign::Thickness* pcThickness = static_cast(DressUpView->getObject()); - App::DocumentObject* base = pcThickness->Base.getValue(); - // get all fillet references - std::vector refs = pcThickness->Base.getSubValues(); // the ref index is the same as the listWidgetReferences index // so we can erase using the row number of the element to be deleted int rowNumber = ui->listWidgetReferences->row(selectedList.at(i)); + // erase the reference refs.erase(refs.begin() + rowNumber); setupTransaction(); + // update the object pcThickness->Base.setValue(base, refs); + // remove from the list ui->listWidgetReferences->model()->removeRow(rowNumber); - pcThickness->getDocument()->recomputeFeature(pcThickness); } + // recompute the feature + pcThickness->getDocument()->recomputeFeature(pcThickness); + // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { deleteAction->setEnabled(false);