From c326f33b5092ac2f01fb39ac3d256256a975fa42 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 31 Aug 2016 11:00:05 +0300 Subject: [PATCH] Fix of crash of execution of some python scripts in GUI. This allows to update OB correctly even if composite features take subs with delay (subs are free before). --- src/FeaturesAPI/FeaturesAPI_Extrusion.cpp | 3 +++ src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp | 3 +++ src/FeaturesAPI/FeaturesAPI_Revolution.cpp | 3 +++ src/FeaturesAPI/FeaturesAPI_RevolutionBoolean.cpp | 3 +++ src/ModelAPI/ModelAPI_Document.h | 5 +++-- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp b/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp index e2f317182..4692cc103 100644 --- a/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Extrusion.cpp @@ -113,6 +113,9 @@ FeaturesAPI_Extrusion::~FeaturesAPI_Extrusion() void FeaturesAPI_Extrusion::setNestedSketch(const ModelHighAPI_Reference& theSketch) { mysketch->setValue(theSketch.feature()); + // to inform that the history is updated due to the sketch moved under the composite feature + if (theSketch.feature().get()) + theSketch.feature()->document()->updateHistory(ModelAPI_Feature::group()); mybaseObjects->clear(); mybaseObjects->append(theSketch.feature()->firstResult(), GeomShapePtr()); diff --git a/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp index d384af987..386afe554 100644 --- a/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp +++ b/src/FeaturesAPI/FeaturesAPI_ExtrusionBoolean.cpp @@ -26,6 +26,9 @@ FeaturesAPI_ExtrusionBoolean::~FeaturesAPI_ExtrusionBoolean() void FeaturesAPI_ExtrusionBoolean::setNestedSketch(const ModelHighAPI_Reference& theSketch) { mysketch->setValue(theSketch.feature()); + // to inform that the history is updated due to the sketch moved under the composite feature + if (theSketch.feature().get()) + theSketch.feature()->document()->updateHistory(ModelAPI_Feature::group()); mybaseObjects->clear(); mybaseObjects->append(theSketch.feature()->firstResult(), GeomShapePtr()); diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.cpp b/src/FeaturesAPI/FeaturesAPI_Revolution.cpp index 6c09db9f2..e07354139 100644 --- a/src/FeaturesAPI/FeaturesAPI_Revolution.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Revolution.cpp @@ -74,6 +74,9 @@ FeaturesAPI_Revolution::~FeaturesAPI_Revolution() void FeaturesAPI_Revolution::setNestedSketch(const ModelHighAPI_Reference& theSketch) { mysketch->setValue(theSketch.feature()); + // to inform that the history is updated due to the sketch moved under the composite feature + if (theSketch.feature().get()) + theSketch.feature()->document()->updateHistory(ModelAPI_Feature::group()); mybaseObjects->clear(); mybaseObjects->append(theSketch.feature()->firstResult(), GeomShapePtr()); diff --git a/src/FeaturesAPI/FeaturesAPI_RevolutionBoolean.cpp b/src/FeaturesAPI/FeaturesAPI_RevolutionBoolean.cpp index 097fbfbdb..b463b9a11 100644 --- a/src/FeaturesAPI/FeaturesAPI_RevolutionBoolean.cpp +++ b/src/FeaturesAPI/FeaturesAPI_RevolutionBoolean.cpp @@ -26,6 +26,9 @@ FeaturesAPI_RevolutionBoolean::~FeaturesAPI_RevolutionBoolean() void FeaturesAPI_RevolutionBoolean::setNestedSketch(const ModelHighAPI_Reference& theSketch) { mysketch->setValue(theSketch.feature()); + // to inform that the history is updated due to the sketch moved under the composite feature + if (theSketch.feature().get()) + theSketch.feature()->document()->updateHistory(ModelAPI_Feature::group()); mybaseObjects->clear(); mybaseObjects->append(theSketch.feature()->firstResult(), GeomShapePtr()); diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index f8e53575d..17bf94356 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -168,14 +168,15 @@ public: virtual bool isLater(std::shared_ptr theLater, std::shared_ptr theCurrent) const = 0; + //! Internally makes document know that feature was removed or added in history after creation + MODELAPI_EXPORT virtual void updateHistory(const std::string theGroup) = 0; + protected: //! Only for SWIG wrapping it is here MODELAPI_EXPORT ModelAPI_Document(); //! Internally makes document know that feature was removed or added in history after creation MODELAPI_EXPORT virtual void updateHistory(const std::shared_ptr theObject) = 0; - //! Internally makes document know that feature was removed or added in history after creation - MODELAPI_EXPORT virtual void updateHistory(const std::string theGroup) = 0; friend class ModelAPI_Object; // to add or remove from the history friend class ModelAPI_Result; // to add or remove from the history -- 2.39.2