From c9436fb8fbf01219d715cca986a2165594098377 Mon Sep 17 00:00:00 2001 From: Artem Zhidkov Date: Thu, 19 Mar 2020 22:39:48 +0300 Subject: [PATCH] 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. --- .../SketchPlugin_MacroBSpline.cpp | 51 ------------------- src/SketchPlugin/SketchPlugin_MacroBSpline.h | 7 +-- 2 files changed, 1 insertion(+), 57 deletions(-) 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(); -- 2.39.2