From: azv Date: Sat, 25 Nov 2017 16:17:39 +0000 (+0300) Subject: Avoid crash while loading dumped document containing folders X-Git-Tag: V_2.10.0RC~123^2~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=afcb6562f38474c4bfcbdd8269a377a697c85934;p=modules%2Fshaper.git Avoid crash while loading dumped document containing folders --- diff --git a/src/ModelHighAPI/ModelHighAPI_Folder.cpp b/src/ModelHighAPI/ModelHighAPI_Folder.cpp index cbb986198..a4402a5e6 100644 --- a/src/ModelHighAPI/ModelHighAPI_Folder.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Folder.cpp @@ -45,8 +45,15 @@ bool ModelHighAPI_Folder::initialize() return false; } - SET_ATTRIBUTE(firstFeature, ModelAPI_AttributeReference, ModelAPI_Folder::FIRST_FEATURE_ID()); - SET_ATTRIBUTE(lastFeature, ModelAPI_AttributeReference, ModelAPI_Folder::LAST_FEATURE_ID()); + myFirstFeature = myFolder->reference(ModelAPI_Folder::FIRST_FEATURE_ID()); + if (!myFirstFeature) + return false; + myAttrGetter[ModelAPI_Folder::FIRST_FEATURE_ID()] = "firstFeature"; + + myLastFeature = myFolder->reference(ModelAPI_Folder::LAST_FEATURE_ID()); + if (!myLastFeature) + return false; + myAttrGetter[ModelAPI_Folder::LAST_FEATURE_ID()] = "lastFeature"; return true; } diff --git a/src/ModelHighAPI/ModelHighAPI_Folder.h b/src/ModelHighAPI/ModelHighAPI_Folder.h index 6713ff0a0..8128df05a 100644 --- a/src/ModelHighAPI/ModelHighAPI_Folder.h +++ b/src/ModelHighAPI/ModelHighAPI_Folder.h @@ -23,7 +23,6 @@ //-------------------------------------------------------------------------------------- #include -#include #include @@ -51,11 +50,11 @@ public: /// First feature reference std::shared_ptr firstFeature() const - { return myfirstFeature; } + { return myFirstFeature; } /// Last feature reference std::shared_ptr lastFeature() const - { return mylastFeature; } + { return myLastFeature; } /// Dump wrapped feature MODELHIGHAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; @@ -66,8 +65,8 @@ protected: private: std::shared_ptr myFolder; - std::shared_ptr myfirstFeature; - std::shared_ptr mylastFeature; + std::shared_ptr myFirstFeature; + std::shared_ptr myLastFeature; }; //--------------------------------------------------------------------------------------