From 29235b54a59fcf86e6474892e4fb51e25007545c Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 11 Apr 2017 19:29:46 +0300 Subject: [PATCH] Issue #2129 Crash when clicking on Length after multiple selections --- src/PartSet/PartSet_WidgetPoint2DFlyout.cpp | 10 ++++++++++ src/PartSet/PartSet_WidgetPoint2DFlyout.h | 7 +++++++ src/PartSet/PartSet_WidgetPoint2d.cpp | 19 +++++++++++-------- 3 files changed, 28 insertions(+), 8 deletions(-) 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; -- 2.39.2