From e151691ef2dae3825508a710331a11c81205f05e Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 23 Aug 2016 13:45:46 +0300 Subject: [PATCH] Explicitly call execute for nested features before referring --- src/ConstructionAPI/ConstructionAPI_Point.cpp | 2 +- src/FeaturesAPI/FeaturesAPI_Boolean.cpp | 2 +- src/ModelHighAPI/ModelHighAPI_Interface.cpp | 15 ++++++++------- src/ModelHighAPI/ModelHighAPI_Interface.h | 3 ++- src/ModelHighAPI/ModelHighAPI_Reference.cpp | 5 +++++ src/SketchSolver/SketchSolver_Manager.cpp | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/ConstructionAPI/ConstructionAPI_Point.cpp b/src/ConstructionAPI/ConstructionAPI_Point.cpp index 76be0f73b..5e9aea6e1 100644 --- a/src/ConstructionAPI/ConstructionAPI_Point.cpp +++ b/src/ConstructionAPI/ConstructionAPI_Point.cpp @@ -83,7 +83,7 @@ void ConstructionAPI_Point::setByXYZ(const ModelHighAPI_Double& theX, fillAttribute(theY, myy); fillAttribute(theZ, myz); - execute(); + execute(false); } /*//================================================================================================== diff --git a/src/FeaturesAPI/FeaturesAPI_Boolean.cpp b/src/FeaturesAPI/FeaturesAPI_Boolean.cpp index 062731c89..f47eab172 100644 --- a/src/FeaturesAPI/FeaturesAPI_Boolean.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Boolean.cpp @@ -30,7 +30,7 @@ FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr fillAttribute(theMainObjects, mymainObjects); fillAttribute(theToolObjects, mytoolObjects); - execute(); + execute(false); } } diff --git a/src/ModelHighAPI/ModelHighAPI_Interface.cpp b/src/ModelHighAPI/ModelHighAPI_Interface.cpp index 401ba5467..cfea20834 100644 --- a/src/ModelHighAPI/ModelHighAPI_Interface.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Interface.cpp @@ -54,14 +54,15 @@ const std::string& ModelHighAPI_Interface::getKind() const return feature()->getKind(); } -void ModelHighAPI_Interface::execute() +void ModelHighAPI_Interface::execute(bool isForce) { - //SessionPtr aMgr = ModelAPI_Session::get(); - //ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - //FeaturePtr aFeature = feature(); - //if(aFactory->validate(aFeature)) { - // aFeature->execute(); - //} + if (isForce) { + SessionPtr aMgr = ModelAPI_Session::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + FeaturePtr aFeature = feature(); + if(aFactory->validate(aFeature)) + aFeature->execute(); + } Events_Loop* aLoop = Events_Loop::loop(); aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); diff --git a/src/ModelHighAPI/ModelHighAPI_Interface.h b/src/ModelHighAPI/ModelHighAPI_Interface.h index f4c156fb7..43d267642 100644 --- a/src/ModelHighAPI/ModelHighAPI_Interface.h +++ b/src/ModelHighAPI/ModelHighAPI_Interface.h @@ -49,8 +49,9 @@ public: const std::string& getKind() const; /// Shortcut for feature()->execute() + /// \param isForce start execution of feature instead of sending events MODELHIGHAPI_EXPORT - void execute(); + void execute(bool isForce = false); /// Shortcut for feature()->data()->setName() MODELHIGHAPI_EXPORT diff --git a/src/ModelHighAPI/ModelHighAPI_Reference.cpp b/src/ModelHighAPI/ModelHighAPI_Reference.cpp index 20a07f53b..f427b7e92 100644 --- a/src/ModelHighAPI/ModelHighAPI_Reference.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Reference.cpp @@ -25,6 +25,11 @@ ModelHighAPI_Reference::ModelHighAPI_Reference( const std::shared_ptr & theValue) : myObject(std::shared_ptr(theValue->defaultResult())) { + // the result is not constructed yet, forcibly do it + if (!myObject) { + theValue->execute(true); + myObject = std::shared_ptr(theValue->defaultResult()); + } } ModelHighAPI_Reference::~ModelHighAPI_Reference() diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index 4748424f8..61c0547b0 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -279,7 +279,7 @@ bool SketchSolver_Manager::changeWorkplane(CompositeFeaturePtr theSketch) } myGroups.push_back(aNewGroup); } - return aResult; + return aResult || isUpdated; } // ============================================================================ -- 2.39.2