From afcb6562f38474c4bfcbdd8269a377a697c85934 Mon Sep 17 00:00:00 2001 From: azv Date: Sat, 25 Nov 2017 19:17:39 +0300 Subject: [PATCH] Avoid crash while loading dumped document containing folders --- src/ModelHighAPI/ModelHighAPI_Folder.cpp | 11 +++++++++-- src/ModelHighAPI/ModelHighAPI_Folder.h | 9 ++++----- 2 files changed, 13 insertions(+), 7 deletions(-) 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; }; //-------------------------------------------------------------------------------------- -- 2.39.2