From 674569fb1280e3e4a9bbf141a817750253fbe662 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 4 May 2016 15:05:54 +0300 Subject: [PATCH] Issue #1452 Fatal error when create Distance constraint on construction vertex --- src/ModuleBase/ModuleBase_WidgetValidated.cpp | 7 +++++-- src/PartSet/PartSet_SketcherMgr.cpp | 13 ++++++++++--- src/PartSet/PartSet_SketcherMgr.h | 3 ++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 98ba56f71..390c37793 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -163,16 +163,19 @@ bool ModuleBase_WidgetValidated::isValidSelectionForAttribute(const ModuleBase_V restoreAttributeValue(theAttribute, aValid); blockAttribute(theAttribute, false, isFlushesActived, isAttributeSetInitializedBlocked); + /// NDS: The following rows are commented for issue #1452 (to be removed after debug) + /// This is not correct to perform it here because it might cause update selection and + /// the selection mechanizm will be circled: use the scenario of the bug with preselected point. // In particular case the results are deleted and called as redisplayed inside of this // highlight-selection, to they must be flushed as soon as possible. // Example: selection of group-vertices subshapes with shift pressend on body. Without // these 4 lines below the application crashes because of left presentations on // removed results still in the viewer. - static Events_ID aDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED); + /*static Events_ID aDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED); static Events_ID aRedispEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); Events_Loop::loop()->flush(aDeletedEvent); Events_Loop::loop()->flush(aRedispEvent); - + */ return aValid; } diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 51d5043cb..6b54a5ecd 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1030,8 +1030,12 @@ bool PartSet_SketcherMgr::operationActivatedByPreselection() bool aCanCommitOperation = true; ModuleBase_OperationFeature* aFOperation = dynamic_cast (anOperation); - if (aFOperation && PartSet_SketcherMgr::isDistanceOperation(aFOperation)) - aCanCommitOperation = setDistanceValueByPreselection(anOperation, myModule->workshop()); + if (aFOperation && PartSet_SketcherMgr::isDistanceOperation(aFOperation)) { + bool aValueAccepted = setDistanceValueByPreselection(anOperation, myModule->workshop(), + aCanCommitOperation); + if (!aValueAccepted) + return isOperationStopped; + } if (aCanCommitOperation) isOperationStopped = anOperation->commit(); @@ -1325,9 +1329,11 @@ void PartSet_SketcherMgr::onPlaneSelected(const std::shared_ptr& th } bool PartSet_SketcherMgr::setDistanceValueByPreselection(ModuleBase_Operation* theOperation, - ModuleBase_IWorkshop* theWorkshop) + ModuleBase_IWorkshop* theWorkshop, + bool& theCanCommitOperation) { bool isValueAccepted = false; + theCanCommitOperation = false; ModuleBase_OperationFeature* aFOperation = dynamic_cast (theOperation); @@ -1389,6 +1395,7 @@ bool PartSet_SketcherMgr::setDistanceValueByPreselection(ModuleBase_Operation* t } anEditor->setCursorPosition(aX, anY); isValueAccepted = anEditor->showPopupEditor(false); + theCanCommitOperation = true; } } } diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 062bd102f..c739c2852 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -306,7 +306,8 @@ private: /// are filled by preseletion /// \return true if the value is accepted static bool setDistanceValueByPreselection(ModuleBase_Operation* theOperation, - ModuleBase_IWorkshop* theWorkshop); + ModuleBase_IWorkshop* theWorkshop, + bool& theCanCommitOperation); typedef QMap, std::set > > FeatureToSelectionMap; -- 2.39.2