Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / ModuleBase / ModuleBase_Operation.cpp
index b3250ff01416cf777304481895b17b9dae6d0174..1011fa2ca382a3709a44f0cb8427fc9e9a9131bb 100644 (file)
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Document.h>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
 
 /*!
  \brief Constructor
@@ -29,7 +34,6 @@ ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* parent
       myExecStatus(Rejected),
       myOperationId(theId)
 {
-  myFeature = ModelAPI_PluginManager::get()->createFeature(theId.toStdString());
 }
 
 /*!
@@ -251,6 +255,13 @@ void ModuleBase_Operation::commit()
  */
 void ModuleBase_Operation::storeReal(double theValue)
 {
+  if(!myFeature){
+    #ifdef _DEBUG
+    qDebug() << "ModuleBase_Operation::storeReal: " <<
+        "trying to store value without opening a transaction.";
+    #endif
+    return;
+  }
   QString anId = sender()->objectName();
   std::shared_ptr<ModelAPI_Object> aData = myFeature->data();
   std::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(anId.toStdString());
@@ -276,6 +287,8 @@ bool ModuleBase_Operation::isReadyToStart() const
  */
 void ModuleBase_Operation::startOperation()
 {
+  std::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
+  myFeature = aDoc->addFeature(myOperationId.toStdString());
   //emit callSlot();
   //commit();
 }