diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index d928a21171..8cb78b84bc 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -300,16 +300,6 @@ TaskDlgDraftParameters::~TaskDlgDraftParameters() = default; //==== calls from the TaskView =============================================================== - -//void TaskDlgDraftParameters::open() -//{ -// // a transaction is already open at creation time of the draft -// if (!Gui::Command::hasPendingCommand()) { -// QString msg = QObject::tr("Edit draft"); -// Gui::Command::openCommand((const char*)msg.toUtf8()); -// } -//} - bool TaskDlgDraftParameters::accept() { auto tobj = vp->getObject(); @@ -328,13 +318,6 @@ bool TaskDlgDraftParameters::accept() draftparameter->getLine(obj, strings); std::string pullDirection = buildLinkSingleSubPythonStr(obj, strings); - // Force the user to select a neutral plane - // if (neutralPlane.empty() || neutralPlane == "None") { - // QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Missing neutral plane"), - // QObject::tr("Please select a plane or an edge plus a pull direction")); - // return false; - // } - FCMD_OBJ_CMD(tobj,"Angle = " << draftparameter->getAngle()); FCMD_OBJ_CMD(tobj,"Reversed = " << draftparameter->getReversed()); if(neutralPlane.empty()) diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp index 409e30c1a9..da0db81154 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp @@ -27,6 +27,7 @@ #endif #include +#include #include #include #include @@ -564,8 +565,7 @@ bool TaskExtrudeParameters::hasProfileFace(PartDesign::ProfileBased* profile) co void TaskExtrudeParameters::fillDirectionCombo() { - bool oldVal_blockUpdate = blockUpdate; - blockUpdate = true; + Base::StateLocker lock(getUpdateBlockRef(), true); if (axesInList.empty()) { bool hasFace = false; @@ -628,8 +628,6 @@ void TaskExtrudeParameters::fillDirectionCombo() ui->directionCB->setCurrentIndex(indexOfCurrent); if (hasCustom) ui->directionCB->setCurrentIndex(DirectionModes::Custom); - - blockUpdate = oldVal_blockUpdate; } void TaskExtrudeParameters::addAxisToCombo(App::DocumentObject* linkObj, std::string linkSubname, diff --git a/src/Mod/PartDesign/Gui/TaskFeatureParameters.h b/src/Mod/PartDesign/Gui/TaskFeatureParameters.h index f26650af50..b3fb38b2e6 100644 --- a/src/Mod/PartDesign/Gui/TaskFeatureParameters.h +++ b/src/Mod/PartDesign/Gui/TaskFeatureParameters.h @@ -58,9 +58,28 @@ private: /** Notifies when the object is about to be removed. */ void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) override; +protected: + bool isUpdateBlocked() const + { + return blockUpdate; + } + + bool& getUpdateBlockRef() + { + return blockUpdate; + } + + void setUpdateBlocked(bool value) + { + blockUpdate = value; + } + + protected: PartDesignGui::ViewProvider *vp; /// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature() + +private: bool blockUpdate; }; diff --git a/src/Mod/PartDesign/Gui/TaskHelixParameters.cpp b/src/Mod/PartDesign/Gui/TaskHelixParameters.cpp index 9f9e2b15f7..138d3b9222 100644 --- a/src/Mod/PartDesign/Gui/TaskHelixParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskHelixParameters.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -177,8 +178,7 @@ void TaskHelixParameters::showCoordinateAxes() void TaskHelixParameters::fillAxisCombo(bool forceRefill) { - bool oldVal_blockUpdate = blockUpdate; - blockUpdate = true; + Base::StateLocker lock(getUpdateBlockRef(), true); if (axesInList.empty()) forceRefill = true;//not filled yet, full refill @@ -201,8 +201,6 @@ void TaskHelixParameters::fillAxisCombo(bool forceRefill) int indexOfCurrent = addCurrentLink(); if (indexOfCurrent != -1) ui->axis->setCurrentIndex(indexOfCurrent); - - blockUpdate = oldVal_blockUpdate; } void TaskHelixParameters::addSketchAxes() diff --git a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp index f8d8b98f61..5746eb32fb 100644 --- a/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskHoleParameters.cpp @@ -281,7 +281,7 @@ void TaskHoleParameters::threadedChanged() // update view not active if modeling threads // this will also ensure that the feature is recomputed. ui->UpdateView->setEnabled(ui->Threaded->isChecked() && ui->ModelThread->isChecked()); - blockUpdate = ui->Threaded->isChecked() && ui->ModelThread->isChecked() && !(ui->UpdateView->isChecked()); + setUpdateBlocked(ui->Threaded->isChecked() && ui->ModelThread->isChecked() && !(ui->UpdateView->isChecked())); pcHole->Threaded.setValue(ui->Threaded->isChecked()); recomputeFeature(); @@ -296,7 +296,7 @@ void TaskHoleParameters::modelThreadChanged() // update view not active if modeling threads // this will also ensure that the feature is recomputed. ui->UpdateView->setEnabled(ui->Threaded->isChecked() && ui->ModelThread->isChecked()); - blockUpdate = ui->Threaded->isChecked() && ui->ModelThread->isChecked() && !(ui->UpdateView->isChecked()); + setUpdateBlocked(ui->Threaded->isChecked() && ui->ModelThread->isChecked() && !(ui->UpdateView->isChecked())); // conditional enabling of thread modeling options ui->UseCustomThreadClearance->setEnabled(ui->Threaded->isChecked() && ui->ModelThread->isChecked()); @@ -310,7 +310,7 @@ void TaskHoleParameters::modelThreadChanged() void TaskHoleParameters::updateViewChanged(bool isChecked) { - blockUpdate = !isChecked; + setUpdateBlocked(!isChecked); recomputeFeature(); } diff --git a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp index 99df6e9941..b43a043f90 100644 --- a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp @@ -86,7 +86,7 @@ TaskRevolutionParameters::TaskRevolutionParameters(PartDesignGui::ViewProvider* setupDialog(); - blockUpdate = false; + setUpdateBlocked(false); updateUI(ui->changeMode->currentIndex()); connectSignals(); @@ -185,7 +185,7 @@ void TaskRevolutionParameters::translateModeList(int index) void TaskRevolutionParameters::fillAxisCombo(bool forceRefill) { - Base::StateLocker lock(blockUpdate, true); + Base::StateLocker lock(getUpdateBlockRef(), true); if (axesInList.empty()) forceRefill = true;//not filled yet, full refill @@ -348,9 +348,9 @@ void TaskRevolutionParameters::connectSignals() void TaskRevolutionParameters::updateUI(int index) { - if (blockUpdate) + if (isUpdateBlocked()) return; - Base::StateLocker lock(blockUpdate, true); + Base::StateLocker lock(getUpdateBlockRef(), true); fillAxisCombo(); setCheckboxes(static_cast(index)); } @@ -485,7 +485,7 @@ void TaskRevolutionParameters::onAngle2Changed(double len) void TaskRevolutionParameters::onAxisChanged(int num) { - if (blockUpdate) + if (isUpdateBlocked()) return; PartDesign::ProfileBased* pcRevolution = static_cast(vp->getObject());