From d232f17e2397cb8b9200e25aef86a4bbda7532fc Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 6 Jan 2022 02:41:20 +0100 Subject: [PATCH] [PD] Hole: don't call onChanged on restoration fixes the issue reported here: https://forum.freecadweb.org/viewtopic.php?f=10&t=65035 --- src/Mod/PartDesign/App/FeatureHole.cpp | 36 +++++++++++++++----------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index 3f799dfd4d..b926f0fb93 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -1435,8 +1435,10 @@ void Hole::onChanged(const App::Property* prop) } else if (prop == &ThreadSize) { updateDiameterParam(); - updateThreadDepthParam(); - // updateHoleCutParams() will later automatically be called because updateDiameterParam() changes &Diameter + if (!isRestoring()) + updateThreadDepthParam(); + // updateHoleCutParams() will later automatically be called because + // updateDiameterParam() changes &Diameter } else if (prop == &ThreadFit) { updateDiameterParam(); @@ -1466,27 +1468,32 @@ void Hole::onChanged(const App::Property* prop) DrillPoint.setReadOnly(DepthMode != "Dimension"); DrillPointAngle.setReadOnly(DepthMode != "Dimension"); DrillForDepth.setReadOnly(DepthMode != "Dimension"); - if (DepthMode != "Dimension") { - // if through all, set the depth accordingly - Depth.setValue(getThroughAllLength()); - // the thread depth is not dimension, it is the same as the hole depth - ThreadDepth.setValue(getThroughAllLength()); + if (!isRestoring()) { + if (DepthMode != "Dimension") { + // if through all, set the depth accordingly + Depth.setValue(getThroughAllLength()); + // the thread depth is not dimension, it is the same as the hole depth + ThreadDepth.setValue(getThroughAllLength()); + } + updateThreadDepthParam(); } - updateThreadDepthParam(); } else if (prop == &Depth) { - // the depth cannot be greater than the through-all length - if (Depth.getValue() > getThroughAllLength()) - Depth.setValue(getThroughAllLength()); + if (!isRestoring()) { + // the depth cannot be greater than the through-all length + if (Depth.getValue() > getThroughAllLength()) + Depth.setValue(getThroughAllLength()); + } if (std::string(ThreadDepthType.getValueAsString()) != "Dimension") updateDiameterParam(); // make sure diameter and pitch are updated. - // update the thread in every case - updateThreadDepthParam(); + if (!isRestoring()) + updateThreadDepthParam(); } else if (prop == &ThreadDepthType) { - updateThreadDepthParam(); + if (!isRestoring()) + updateThreadDepthParam(); ThreadDepth.setReadOnly(Threaded.getValue() && std::string(ThreadDepthType.getValueAsString()) != "Dimension"); } @@ -1590,7 +1597,6 @@ short Hole::mustExecute() const void Hole::Restore(Base::XMLReader& reader) { ProfileBased::Restore(reader); - updateProps(); }