From 669b2d0993a7872cdf67a96ab67fccc09825b3fd Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 19 Mar 2023 08:46:29 +0100 Subject: [PATCH] Prevent unnecessary update of snapAngle, block signals when auto updating --- src/Mod/Sketcher/Gui/Command.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/Command.cpp b/src/Mod/Sketcher/Gui/Command.cpp index 1c12786baa..742e3fab6e 100644 --- a/src/Mod/Sketcher/Gui/Command.cpp +++ b/src/Mod/Sketcher/Gui/Command.cpp @@ -1208,13 +1208,22 @@ public: } }; + auto updateSpinBox = [](Gui::QuantitySpinBox* spinbox, double value) { + auto currentvalue = spinbox->rawValue(); + + if (currentvalue != value) { + const QSignalBlocker blocker(spinbox); + spinbox->setValue(value); + } + }; + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/Snap"); updateCheckBox(snapToObjects, hGrp->GetBool("SnapToObjects", true)); updateCheckBox(snapToGrid, hGrp->GetBool("SnapToGrid", false)); - snapAngle->setValue(hGrp->GetFloat("SnapAngle", 5.0)); + updateSpinBox(snapAngle, hGrp->GetFloat("SnapAngle", 5.0)); bool snapActivated = hGrp->GetBool("Snap", true); snapToObjects->setEnabled(snapActivated);