From: nds Date: Tue, 11 Apr 2017 16:29:46 +0000 (+0300) Subject: Issue #2129 Crash when clicking on Length after multiple selections X-Git-Tag: V_2.7.0~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=29235b54a59fcf86e6474892e4fb51e25007545c;p=modules%2Fshaper.git Issue #2129 Crash when clicking on Length after multiple selections --- diff --git a/src/PartSet/PartSet_WidgetPoint2DFlyout.cpp b/src/PartSet/PartSet_WidgetPoint2DFlyout.cpp index 3563e950e..9041727f3 100755 --- a/src/PartSet/PartSet_WidgetPoint2DFlyout.cpp +++ b/src/PartSet/PartSet_WidgetPoint2DFlyout.cpp @@ -7,6 +7,7 @@ #include "PartSet_WidgetPoint2DFlyout.h" #include "ModuleBase_WidgetValidator.h" +#include "ModuleBase_ViewerPrs.h" #include #include @@ -26,6 +27,15 @@ PartSet_WidgetPoint2DFlyout::PartSet_WidgetPoint2DFlyout(QWidget* theParent, myWidgetValidator = new ModuleBase_WidgetValidator(this, myWorkshop); } +bool PartSet_WidgetPoint2DFlyout::setSelection(QList& theValues, + const bool theToValidate) +{ + PartSet_WidgetPoint2D::setSelection(theValues, theToValidate); + // true value should be returned to set this control as processed the selection + // to move focus to the next control if it is filled by preselection + return true; +} + bool PartSet_WidgetPoint2DFlyout::isValidSelectionCustom( const std::shared_ptr& theValue) { diff --git a/src/PartSet/PartSet_WidgetPoint2DFlyout.h b/src/PartSet/PartSet_WidgetPoint2DFlyout.h index 8b1a87cb7..4a67d00d6 100755 --- a/src/PartSet/PartSet_WidgetPoint2DFlyout.h +++ b/src/PartSet/PartSet_WidgetPoint2DFlyout.h @@ -30,6 +30,13 @@ public: /// Destructor virtual ~PartSet_WidgetPoint2DFlyout() {}; + /// Set the given wrapped value to the current widget + /// This value should be processed in the widget according to the needs + /// \param theValues the wrapped widget values + /// \param theToValidate a validation flag + virtual bool setSelection(QList>& theValues, + const bool theToValidate); + /// Checks if the selection presentation is valid in widget /// \param theValue a selected presentation in the view /// \return a boolean value diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 150b59095..c81d84b96 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -281,14 +281,17 @@ bool PartSet_WidgetPoint2D::setSelection(QList& theValu return isDone; ModuleBase_ViewerPrsPtr aValue = theValues.takeFirst(); - GeomShapePtr aShape = aValue->shape(); - if (aShape.get() && !aShape->isNull()) { - Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); - double aX, aY; - const TopoDS_Shape& aTDShape = aShape->impl(); - if (getPoint2d(aView, aTDShape, aX, aY)) { - isDone = setPoint(aX, aY); - setConstraintToPoint(aX, aY); + + if (!theToValidate || myWidgetValidator->isValidSelection(aValue)) { + GeomShapePtr aShape = aValue->shape(); + if (aShape.get() && !aShape->isNull()) { + Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); + double aX, aY; + const TopoDS_Shape& aTDShape = aShape->impl(); + if (getPoint2d(aView, aTDShape, aX, aY)) { + isDone = setPoint(aX, aY); + setConstraintToPoint(aX, aY); + } } } return isDone;