Salome HOME
Correct dump of default name of results
[modules/shaper.git] / src / Model / Model_AttributeBoolean.cpp
index 74901271ef27ba3dd9ddedc362bcf23e28f9a327..f603def2d681f8ffbea1fa3b2cf146d286fce82c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeBoolean.cpp
 // Created:     2 june 2014
 // Author:      Vitaly Smetannikov
@@ -12,6 +14,8 @@ void Model_AttributeBoolean::setValue(bool theValue)
 {
   Standard_Boolean aValue = theValue ? Standard_True : Standard_False;
   if (!myIsInitialized || myBool->Get() != aValue) {
+    if (myBool.IsNull())
+      myBool = TDataStd_Integer::Set(myLab, 0);
     myBool->Set(aValue);
     owner()->data()->sendAttributeUpdated(this);
   }
@@ -19,15 +23,12 @@ void Model_AttributeBoolean::setValue(bool theValue)
 
 bool Model_AttributeBoolean::value()
 {
-  return myBool->Get() == Standard_True ;
+  return myIsInitialized && myBool->Get() == Standard_True ;
 }
 
 Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
 {
+  myLab = theLabel;
   // check the attribute could be already presented in this doc (after load document)
   myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myBool) == Standard_True;
-  if (!myIsInitialized) {
-    // create attribute: not initialized by value yet, just zero
-    myBool = TDataStd_Integer::Set(theLabel, 0);
-  }
 }