From: mpv Date: Thu, 17 Sep 2015 08:21:29 +0000 (+0300) Subject: Explicit initialization of myDisabled and myConcealed fields of base objects (to... X-Git-Tag: V_1.4.0~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3d0c457fe845fcc567543e071700ac7121dc51ff;p=modules%2Fshaper.git Explicit initialization of myDisabled and myConcealed fields of base objects (to suppress the memory analysers warnings) --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index fb8b0a1de..a657f75ef 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -607,6 +607,7 @@ FeaturePtr Model_Document::addFeature(std::string theID, const bool theMakeCurre FeaturePtr aFeature = aSession->createFeature(theID, this); if (!aFeature) return aFeature; + aFeature->init(); Model_Document* aDocToAdd; if (!aFeature->documentToAdd().empty()) { // use the customized document to add if (aFeature->documentToAdd() != kind()) { // the root document by default diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 2ac45f731..d3069672a 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -142,7 +142,6 @@ void Model_Objects::addFeature(FeaturePtr theFeature, const FeaturePtr theAfterT // event: feature is added static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); ModelAPI_EventCreator::get()->sendUpdated(theFeature, anEvent); - theFeature->setDisabled(false); // by default created feature is enabled updateHistory(ModelAPI_Feature::group()); } else { // make feature has not-null data anyway theFeature->setData(Model_Data::invalidData()); @@ -601,12 +600,12 @@ void Model_Objects::synchronizeFeatures( aLabIter.Value()->Label().ForgetAllAttributes(); continue; } + aFeature->init(); // this must be before "setData" to redo the sketch line correctly myFeatures.Bind(aFeatureLabel, aFeature); aNewFeatures.insert(aFeature); initData(aFeature, aFeatureLabel, TAG_FEATURE_ARGUMENTS); updateHistory(aFeature); - aFeature->setDisabled(false); // by default created feature is enabled (this allows to recreate the results before "setCurrent" is called) // event: model is updated ModelAPI_EventCreator::get()->sendUpdated(aFeature, aCreateEvent); @@ -796,6 +795,7 @@ void Model_Objects::storeResult(std::shared_ptr theFeatureData, std::shared_ptr theResult, const int theResultIndex) { + theResult->init(); theResult->setDoc(myDoc); initData(theResult, resultLabel(theFeatureData, theResultIndex), TAG_FEATURE_ARGUMENTS); if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 9c5fa59cc..d7e3f46c9 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -16,9 +16,6 @@ Model_ResultBody::Model_ResultBody() { myBuilder = new Model_BodyBuilder(this); - - myIsDisabled = true; // by default it is not initialized and false to be after created - setIsConcealed(false); } void Model_ResultBody::initAttributes() diff --git a/src/Model/Model_ResultCompSolid.cpp b/src/Model/Model_ResultCompSolid.cpp index 633e8cd08..b731fdcef 100755 --- a/src/Model/Model_ResultCompSolid.cpp +++ b/src/Model/Model_ResultCompSolid.cpp @@ -24,8 +24,6 @@ Model_ResultCompSolid::Model_ResultCompSolid() { myBuilder = new Model_BodyBuilder(this); myLastConcealed = false; - setIsConcealed(myLastConcealed); - myIsDisabled = true; // by default it is not initialized and false to be after created updateSubs(shape()); // in case of open, etc. } diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index 11cf883cd..990dee11e 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -44,11 +44,9 @@ std::shared_ptr Model_ResultConstruction::shape() Model_ResultConstruction::Model_ResultConstruction() { - myIsDisabled = true; // by default it is not initialized and false to be after created myIsInHistory = true; myIsInfinite = false; myFacesUpToDate = false; - setIsConcealed(false); } void Model_ResultConstruction::setIsInHistory(const bool isInHistory) diff --git a/src/Model/Model_ResultGroup.cpp b/src/Model/Model_ResultGroup.cpp index 87210b5c5..c952c8b9d 100644 --- a/src/Model/Model_ResultGroup.cpp +++ b/src/Model/Model_ResultGroup.cpp @@ -14,8 +14,6 @@ Model_ResultGroup::Model_ResultGroup(std::shared_ptr theOwnerData) { - myIsDisabled = true; // by default it is not initialized and false to be after created - setIsConcealed(false); myOwnerData = theOwnerData; } diff --git a/src/Model/Model_ResultParameter.cpp b/src/Model/Model_ResultParameter.cpp index 5c0f56a66..731bbde93 100644 --- a/src/Model/Model_ResultParameter.cpp +++ b/src/Model/Model_ResultParameter.cpp @@ -21,6 +21,4 @@ void Model_ResultParameter::initAttributes() Model_ResultParameter::Model_ResultParameter() { - myIsDisabled = true; // by default it is not initialized and false to be after created - setIsConcealed(false); } diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index 7ce87b434..7edb9b2e5 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -50,9 +50,7 @@ std::shared_ptr Model_ResultPart::partDoc() Model_ResultPart::Model_ResultPart() { - myIsDisabled = true; // by default it is not initialized and false to be after created myIsInLoad = false; - setIsConcealed(false); } void Model_ResultPart::activate() diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index f677d5c52..9edfefa4c 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -203,3 +203,8 @@ bool ModelAPI_Feature::isPreviewNeeded() const { return true; } + +void ModelAPI_Feature::init() +{ + myIsDisabled = false; +} diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index aed22e183..2508e6a2e 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -195,7 +195,13 @@ class ModelAPI_Feature : public ModelAPI_Object { return data()->attribute(theID); } - // ----------------------------------------------------------------------------------------------- + protected: + /// This method is called just after creation of the object: it must initialize + /// all fields, normally initialized in the constructor + MODELAPI_EXPORT virtual void init(); + + friend class Model_Document; + friend class Model_Objects; }; //! Pointer on feature object diff --git a/src/ModelAPI/ModelAPI_Object.h b/src/ModelAPI/ModelAPI_Object.h index 3ef14da91..a2d840901 100644 --- a/src/ModelAPI/ModelAPI_Object.h +++ b/src/ModelAPI/ModelAPI_Object.h @@ -77,6 +77,10 @@ class ModelAPI_Object: public ModelAPI_Entity MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay); protected: + /// This method is called just after creation of the object: it must initialize + /// all fields, normally initialized in the constructor + MODELAPI_EXPORT virtual void init() = 0; + /// Sets the data manager of an object (document does) MODELAPI_EXPORT virtual void setData(std::shared_ptr theData); diff --git a/src/ModelAPI/ModelAPI_Result.cpp b/src/ModelAPI/ModelAPI_Result.cpp index 8f0b43c5e..624566416 100644 --- a/src/ModelAPI/ModelAPI_Result.cpp +++ b/src/ModelAPI/ModelAPI_Result.cpp @@ -72,3 +72,9 @@ void ModelAPI_Result::attributeChanged(const std::string& theID) static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get(); aECreator->sendUpdated(data()->attribute(theID)->owner(), EVENT_DISP); } + +void ModelAPI_Result::init() +{ + myIsDisabled = true; // by default it is not initialized and false to be after created + myIsConcealed = false; +} diff --git a/src/ModelAPI/ModelAPI_Result.h b/src/ModelAPI/ModelAPI_Result.h index 7e3e4ebba..fb96df98c 100644 --- a/src/ModelAPI/ModelAPI_Result.h +++ b/src/ModelAPI/ModelAPI_Result.h @@ -68,6 +68,13 @@ class ModelAPI_Result : public ModelAPI_Object /// On change of attribute of the result update presentation of this result: /// for the current moment there are only presentation attributes assigned to results MODELAPI_EXPORT virtual void attributeChanged(const std::string& theID); + +protected: + /// This method is called just after creation of the object: it must initialize + /// all fields, normally initialized in the constructor + MODELAPI_EXPORT virtual void init(); + +friend class Model_Objects; }; //! Pointer on feature object