From: Artem Zhidkov Date: Thu, 19 Mar 2020 19:39:48 +0000 (+0300) Subject: Issue #3192: Crash when moving an extremity of B-Spline in the sketcher X-Git-Tag: V9_5_0a2~29^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c9436fb8fbf01219d715cca986a2165594098377;p=modules%2Fshaper.git Issue #3192: Crash when moving an extremity of B-Spline in the sketcher 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. --- diff --git a/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp b/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp index 100e011e6..48158f1a8 100644 --- a/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroBSpline.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -87,58 +86,8 @@ void SketchPlugin_MacroBSpline::execute() std::list 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& theMessage) -{ - ReentrantMessagePtr aReentrantMessage = - std::dynamic_pointer_cast(theMessage); - if (aReentrantMessage) { - FeaturePtr aCreatedFeature = aReentrantMessage->createdFeature(); - ObjectPtr anObject = aReentrantMessage->selectedObject(); - AttributePtr anAttribute = aReentrantMessage->selectedAttribute(); - std::shared_ptr 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(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(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() { diff --git a/src/SketchPlugin/SketchPlugin_MacroBSpline.h b/src/SketchPlugin/SketchPlugin_MacroBSpline.h index f26d51361..9ecf63d49 100644 --- a/src/SketchPlugin/SketchPlugin_MacroBSpline.h +++ b/src/SketchPlugin/SketchPlugin_MacroBSpline.h @@ -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& theMessage); - /// Use plugin manager for features creation SketchPlugin_MacroBSpline();