From bdd8d257d9975d2fff02d682fb802c196142b649 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 23 Feb 2020 14:58:48 +0100 Subject: [PATCH] PartDesign: [skip ci] optimize when removing items from dress-up features --- src/Mod/PartDesign/Gui/TaskChamferParameters.cpp | 8 ++++---- src/Mod/PartDesign/Gui/TaskDraftParameters.cpp | 8 ++++---- src/Mod/PartDesign/Gui/TaskFilletParameters.cpp | 8 ++++---- src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index cbedda306b..a9e3abeef9 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -169,6 +169,7 @@ void TaskChamferParameters::onRefDeleted(void) App::DocumentObject* base = pcChamfer->Base.getValue(); // get all chamfer references std::vector refs = pcChamfer->Base.getSubValues(); + setupTransaction(); // delete the selection backwards to assure the list index keeps valid for the deletion for (int i = selectedList.count() - 1; i > -1; i--) { @@ -177,15 +178,14 @@ void TaskChamferParameters::onRefDeleted(void) 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); // remove from the list ui->listWidgetReferences->model()->removeRow(rowNumber); } + // update the object + pcChamfer->Base.setValue(base, refs); // recompute the feature - pcChamfer->getDocument()->recomputeFeature(pcChamfer); + pcChamfer->recomputeFeature(); // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index 29aaedeb87..3429c99be6 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -243,6 +243,7 @@ void TaskDraftParameters::onRefDeleted(void) App::DocumentObject* base = pcDraft->Base.getValue(); // get all draft references std::vector refs = pcDraft->Base.getSubValues(); + setupTransaction(); // delete the selection backwards to assure the list index keeps valid for the deletion for (int i = selectedList.count() - 1; i > -1; i--) { @@ -251,15 +252,14 @@ void TaskDraftParameters::onRefDeleted(void) 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); } + // update the object + pcDraft->Base.setValue(base, refs); // recompute the feature - pcDraft->getDocument()->recomputeFeature(pcDraft); + pcDraft->recomputeFeature(); // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index a434f0c139..9b8b8be7f2 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -169,6 +169,7 @@ void TaskFilletParameters::onRefDeleted(void) App::DocumentObject* base = pcFillet->Base.getValue(); // get all fillet references std::vector refs = pcFillet->Base.getSubValues(); + setupTransaction(); // delete the selection backwards to assure the list index keeps valid for the deletion for (int i = selectedList.count()-1; i > -1; i--) { @@ -177,15 +178,14 @@ void TaskFilletParameters::onRefDeleted(void) 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); } + // update the object + pcFillet->Base.setValue(base, refs); // recompute the feature - pcFillet->getDocument()->recomputeFeature(pcFillet); + pcFillet->recomputeFeature(); // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) { diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index 7991cd63e1..f752dc91e5 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -191,6 +191,7 @@ void TaskThicknessParameters::onRefDeleted(void) App::DocumentObject* base = pcThickness->Base.getValue(); // get all thickness references std::vector refs = pcThickness->Base.getSubValues(); + setupTransaction(); // delete the selection backwards to assure the list index keeps valid for the deletion for (int i = selectedList.count() - 1; i > -1; i--) { @@ -199,15 +200,14 @@ void TaskThicknessParameters::onRefDeleted(void) 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); } + // update the object + pcThickness->Base.setValue(base, refs); // recompute the feature - pcThickness->getDocument()->recomputeFeature(pcThickness); + pcThickness->recomputeFeature(); // if there is only one item left, it cannot be deleted if (ui->listWidgetReferences->count() == 1) {