From: nds Date: Fri, 26 Feb 2016 18:11:29 +0000 (+0300) Subject: Crash fix: start rectangle, click 1st point, click 2nd point over axis(to be external... X-Git-Tag: V_2.2.0~52 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0b46ae98feefd9c4f6c9f315315ca4440fde5ee5;p=modules%2Fshaper.git Crash fix: start rectangle, click 1st point, click 2nd point over axis(to be external), click 1st, crash. Fixed object was created, rectangle feature is used as an argument of coincidence constraint. Solution: do not use rectangle feature in the coincidence creating. --- diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index 950a20efa..6dcda35c2 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -34,6 +34,13 @@ #include +// the define to check the activated object as a sub-feature by argument of +// the operation feature. E.g. rectangle feature(operation), line(in argument) to be not activated +//#define DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE +#ifdef DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE +#include +#endif + #ifdef _DEBUG #include #endif @@ -187,6 +194,25 @@ bool ModuleBase_OperationFeature::hasObject(ObjectPtr theObj) const if (theObj == (*aIt)) return true; } +#ifdef DEBUG_DO_NOT_ACTIVATE_SUB_FEATURE + FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObj); + std::list anAttributes = aFeature->data()->attributes( + ModelAPI_AttributeRefList::typeId()); + std::list::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end(); + bool aFoundObject = false; + for (; anIt != aLast && !aFoundObject; anIt++) { + std::shared_ptr aCurSelList = + std::dynamic_pointer_cast(*anIt); + for (int i = 0, aNb = aCurSelList->size(); i < aNb && !aFoundObject; i++) { + ObjectPtr anObject = aCurSelList->object(i); + FeaturePtr aFeature = std::dynamic_pointer_cast(anObject); + if (aFeature.get()) { + aFoundObject = anObjectFeature == aFeature; + } + } + } + return aFoundObject; +#endif } return false; } diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 072143b24..50ac3e3ee 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -410,6 +410,8 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous if (theEvent->button() != Qt::LeftButton) return; + bool isCoincidenceEnabled = MyFeaturesForCoincedence.contains(myFeature->getKind().c_str()); + ModuleBase_ISelection* aSelection = myWorkshop->selection(); Handle(V3d_View) aView = theWnd->v3dView(); // TODO: This fragment doesn't work because bug in OCC Viewer. It can be used after fixing. @@ -427,11 +429,13 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous aSPFeature = std::dynamic_pointer_cast(aSelectedFeature); if ((!aSPFeature && !aShape.IsNull()) || (aSPFeature.get() && aSPFeature->isExternal())) { - anExternal = true; - ResultPtr aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch); - if (!aFixedObject.get()) - aFixedObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch); - + ResultPtr aFixedObject; + if (isCoincidenceEnabled) { + anExternal = true; + aFixedObject = PartSet_Tools::findFixedObjectByExternal(aShape, aObject, mySketch); + if (!aFixedObject.get()) + aFixedObject = PartSet_Tools::createFixedObjectByExternal(aShape, aObject, mySketch); + } double aX, aY; if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) { // do not create a constraint to the point, which already used by the feature @@ -455,8 +459,8 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous } } } - - setConstraintWith(aFixedObject); + if (aFixedObject.get()) + setConstraintWith(aFixedObject); // fignal updated should be flushed in order to visualize possible created external objects // e.g. selection of trihedron axis when input end arc point updateObject(feature()); @@ -486,7 +490,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY); } else if (aShape.ShapeType() == TopAbs_EDGE) { - if (MyFeaturesForCoincedence.contains(myFeature->getKind().c_str())) { + if (isCoincidenceEnabled) { setConstraintWith(aObject); setValueState(Stored); // in case of edge selection, Apply state should also be updated