]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3192: Crash when moving an extremity of B-Spline in the sketcher
authorArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 19 Mar 2020 19:39:48 +0000 (22:39 +0300)
committerArtem Zhidkov <Artem.Zhidkov@opencascade.com>
Thu, 19 Mar 2020 19:40:26 +0000 (22:40 +0300)
Operation of B-spline creation should not be re-entrant due to its nature: the construction of B-spline should be finished before the next curve will be created.

src/SketchPlugin/SketchPlugin_MacroBSpline.cpp
src/SketchPlugin/SketchPlugin_MacroBSpline.h

index 100e011e66d33cafc01038c3bd2fb92a1f68f393..48158f1a826c86f48da608976153abbee07f3261 100644 (file)
@@ -31,7 +31,6 @@
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_AttributeRefAttrList.h>
 #include <ModelAPI_Events.h>
-#include <ModelAPI_EventReentrantMessage.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
@@ -87,58 +86,8 @@ void SketchPlugin_MacroBSpline::execute()
     std::list<FeaturePtr> aControlPoles;
     createControlPolygon(aBSpline, aControlPoles);
     constraintsForPoles(aControlPoles);
-
-    // message to init reentrant operation
-    static Events_ID anId = ModelAPI_EventReentrantMessage::eventId();
-    ReentrantMessagePtr aMessage(new ModelAPI_EventReentrantMessage(anId, this));
-    // set here the last pole to make coincidence with the start point of the next B-spline curve
-    aMessage->setCreatedFeature(aControlPoles.back());
-    Events_Loop::loop()->send(aMessage);
-  }
-}
-
-// LCOV_EXCL_START
-std::string SketchPlugin_MacroBSpline::processEvent(
-                                              const std::shared_ptr<Events_Message>& theMessage)
-{
-  ReentrantMessagePtr aReentrantMessage =
-      std::dynamic_pointer_cast<ModelAPI_EventReentrantMessage>(theMessage);
-  if (aReentrantMessage) {
-    FeaturePtr aCreatedFeature = aReentrantMessage->createdFeature();
-    ObjectPtr anObject = aReentrantMessage->selectedObject();
-    AttributePtr anAttribute = aReentrantMessage->selectedAttribute();
-    std::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = aReentrantMessage->clickedPoint();
-
-    if (aClickedPoint) {
-      // fill points list (it consists of 2 points to make editable the second one)
-      AttributePoint2DArrayPtr aPointArrayAttr =
-          std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>(attribute(POLES_ID()));
-      aPointArrayAttr->setSize(2);
-      aPointArrayAttr->setPnt(0, aClickedPoint);
-      aPointArrayAttr->setPnt(1, aClickedPoint);
-
-      // fill weights
-      AttributeDoubleArrayPtr aWeightsArrayAttr = data()->realArray(WEIGHTS_ID());
-      aWeightsArrayAttr->setSize(2);
-      aWeightsArrayAttr->setValue(0, 1.0);
-      aWeightsArrayAttr->setValue(1, 1.0);
-
-      // fill reference attribute
-      AttributeRefAttrListPtr aRefAttrList =
-          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(attribute(REF_POLES_ID()));
-      if (anAttribute) {
-        if (!anAttribute->owner() || !anAttribute->owner()->data()->isValid()) {
-          if (aCreatedFeature && anAttribute->id() == SketchPlugin_Point::COORD_ID())
-            anAttribute = aCreatedFeature->attribute(SketchPlugin_Point::COORD_ID());
-        }
-        aRefAttrList->append(anAttribute);
-      }
-    }
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
   }
-  return std::string();
 }
-// LCOV_EXCL_STOP
 
 FeaturePtr SketchPlugin_MacroBSpline::createBSplineFeature()
 {
index f26d51361a9d9118663bf274652a8b341a6c6c2d..9ecf63d49063d2a16b0853916792e35773ac2034 100644 (file)
@@ -38,8 +38,7 @@ class GeomDataAPI_Point2DArray;
  * \brief Feature for creation of the new B-spline in Sketch.
  */
 class SketchPlugin_MacroBSpline : public SketchPlugin_SketchEntity,
-                                  public GeomAPI_IPresentable,
-                                  public ModelAPI_IReentrant
+                                  public GeomAPI_IPresentable
 {
 public:
   /// B-spline macro feature kind
@@ -100,10 +99,6 @@ public:
 
   SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
 
-  /// Apply information of the message to current object. It fills reference object,
-  /// tangent type and tangent point refence in case of tangent arc
-  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
-
   /// Use plugin manager for features creation
   SketchPlugin_MacroBSpline();