Skip to content

Commit

Permalink
PartDesign: [skip ci] optimize when removing items from dress-up feat…
Browse files Browse the repository at this point in the history
…ures
  • Loading branch information
wwmayer committed Feb 23, 2020
1 parent da6352c commit bdd8d25
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/Mod/PartDesign/Gui/TaskChamferParameters.cpp
Expand Up @@ -169,6 +169,7 @@ void TaskChamferParameters::onRefDeleted(void)
App::DocumentObject* base = pcChamfer->Base.getValue();
// get all chamfer references
std::vector<std::string> 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--) {
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/PartDesign/Gui/TaskDraftParameters.cpp
Expand Up @@ -243,6 +243,7 @@ void TaskDraftParameters::onRefDeleted(void)
App::DocumentObject* base = pcDraft->Base.getValue();
// get all draft references
std::vector<std::string> 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--) {
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/PartDesign/Gui/TaskFilletParameters.cpp
Expand Up @@ -169,6 +169,7 @@ void TaskFilletParameters::onRefDeleted(void)
App::DocumentObject* base = pcFillet->Base.getValue();
// get all fillet references
std::vector<std::string> 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--) {
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp
Expand Up @@ -191,6 +191,7 @@ void TaskThicknessParameters::onRefDeleted(void)
App::DocumentObject* base = pcThickness->Base.getValue();
// get all thickness references
std::vector<std::string> 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--) {
Expand All @@ -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) {
Expand Down

0 comments on commit bdd8d25

Please sign in to comment.