Salome HOME
Issue #19187: B-Splines - Crash with specific scenario
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 8 Jun 2020 07:24:25 +0000 (10:24 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Mon, 8 Jun 2020 07:24:25 +0000 (10:24 +0300)
Fix the regression related to the previous change. Improve the validator of the Tangent constraint.

src/SketchPlugin/SketchPlugin_Validators.cpp

index f3543bc29affe407f01d8454b775617d56d4ed96..9feba7df8772bba8cba3aa638643262b508a9bee 100644 (file)
@@ -231,9 +231,6 @@ bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute
     std::set<FeaturePtr> aCoincidences = SketchPlugin_Tools::findCoincidentConstraints(aRefFea);
     for (std::set<FeaturePtr>::iterator anIt = aCoincidences.begin();
          anIt != aCoincidences.end() && !isValid; ++anIt) {
-      if ((*anIt)->getKind() == SketchPlugin_ConstraintCoincidenceInternal::ID())
-        continue; // skip internal constraints
-
       std::set<FeaturePtr> aCoinc;
       if (isApplicableCoincidence(*anIt, SketchPlugin_Constraint::ENTITY_A()))
         SketchPlugin_Tools::findCoincidences(*anIt, SketchPlugin_Constraint::ENTITY_B(),
@@ -242,7 +239,13 @@ bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute
         SketchPlugin_Tools::findCoincidences(*anIt, SketchPlugin_Constraint::ENTITY_A(),
                                              aCoinc, true);
 
-      isValid = aCoinc.find(aOtherFea) != aCoinc.end();
+      std::set<FeaturePtr>::iterator aFoundCoinc = aCoinc.find(aOtherFea);
+      if (aFoundCoinc != aCoinc.end()) {
+        // do not take into account internal constraints
+        AttributeReferencePtr aParent =
+            (*aFoundCoinc)->reference(SketchPlugin_SketchEntity::PARENT_ID());
+        isValid = !aParent || !aParent->isInitialized() || aParent->value() != aRefFea;
+      }
     }
   }