Salome HOME
Fix for the problem:
authormpv <mpv@opencascade.com>
Thu, 6 Jul 2017 09:06:31 +0000 (12:06 +0300)
committermpv <mpv@opencascade.com>
Thu, 6 Jul 2017 09:06:31 +0000 (12:06 +0300)
Open document with Sketch and Part (Extrusion is inside)
select Sketch+Part, Delete
create new Part
Bug: it is not activated
activate this new part
bug: this new part contains the Extrusion of the previous part, moreover it uses sketch not presented in the object browser

src/GeomValidators/GeomValidators_Positive.cpp
src/Model/Model_Application.cpp
src/Model/Model_Application.h
src/Model/Model_ResultPart.cpp
src/Model/Model_Session.cpp
src/Model/Model_Session.h
src/ModelAPI/ModelAPI_Session.h
src/PartSetPlugin/PartSetPlugin_Part.cpp

index 446470df27ad40ec1f1dce6dea58e1dbb5fac4be..139239be9aaac39a943194ec5d31c6f98d171eec 100644 (file)
@@ -48,7 +48,6 @@ bool GeomValidators_Positive::isValid(const AttributePtr& theAttribute,
   double aMinValue = 1.e-5;
   if(theArguments.size() == 1) {
     std::list<std::string>::const_iterator anIt = theArguments.begin();
-    char *aErr;
     double aValue = Config_PropManager::stringToDouble((*anIt).c_str());
     if(aValue != 0) {
       // very probably ok
index ed730d1c8578812e38c508d1cd45f5bc3522bca5..a5688b66e5e7f1150ec8bec91434ae16c32cc82c 100644 (file)
@@ -136,9 +136,10 @@ void Model_Application::setLoadByDemand(std::string theID, const int theDocID)
 }
 
 //=======================================================================
-bool Model_Application::isLoadByDemand(std::string theID)
+bool Model_Application::isLoadByDemand(std::string theID, const int theDocIndex)
 {
-  return myLoadedByDemand.find(theID) != myLoadedByDemand.end();
+  return myLoadedByDemand.find(theID) != myLoadedByDemand.end() &&
+    myLoadedByDemand[theID] == theDocIndex;
 }
 
 //=======================================================================
index 8f5526c0de45c2fb7c904253dcba98591a746247..6ec3c8df938bf137bf8346f71fdc1d8d770166ec 100644 (file)
@@ -76,7 +76,7 @@ public:
   //! Defines that specified document must be loaded by demand
   void setLoadByDemand(std::string theID, const int theDocID);
   //! Returns true if specified document must be loaded by demand
-  bool isLoadByDemand(std::string theID);
+  bool isLoadByDemand(std::string theID, const int theDocIndex);
   //! Closes and removes the documents that are not loaded by demand and
   //! not in the given list
   void removeUselessDocuments(std::list<std::shared_ptr<ModelAPI_Document> > theUsedDocs);
index c0c20223f6cb4dc599ff755b755e0add240da1a5..863a681c0196e2b21640e46c99051e9ec451ce53 100644 (file)
@@ -92,7 +92,7 @@ void Model_ResultPart::activate()
   }
   if (!aDocRef->value().get()) {  // create (or open) a document if it is not yet created
     Handle(Model_Application) anApp = Model_Application::getApplication();
-    if (anApp->isLoadByDemand(data()->name())) {
+    if (anApp->isLoadByDemand(data()->name(), aDocRef->docId())) {
       anApp->loadDocument(data()->name(), aDocRef->docId()); // if it is just ne part, load may fail
     } else {
       anApp->createDocument(aDocRef->docId());
index 072382a6fa0a9fcf98f9e8da1d7ce50515c05cb9..10bd28f205db172f7fe67331aa8bf482d3e7ef34 100644 (file)
@@ -332,9 +332,9 @@ std::list<std::shared_ptr<ModelAPI_Document> > Model_Session::allOpenedDocuments
   return aResult;
 }
 
-bool Model_Session::isLoadByDemand(const std::string theDocID)
+bool Model_Session::isLoadByDemand(const std::string theDocID, const int theDocIndex)
 {
-  return Model_Application::getApplication()->isLoadByDemand(theDocID);
+  return Model_Application::getApplication()->isLoadByDemand(theDocID, theDocIndex);
 }
 
 std::shared_ptr<ModelAPI_Document> Model_Session::copy(
index e980774512121d05f8a5971a4f25810689e1a97d..89b9d548c1d5d1b1416b57dde0ad8ec9b92c1aa6 100644 (file)
@@ -113,7 +113,7 @@ class Model_Session : public ModelAPI_Session, public Events_Listener
   MODEL_EXPORT virtual std::list<std::shared_ptr<ModelAPI_Document> > allOpenedDocuments();
 
   /// Returns true if document is not loaded yet
-  MODEL_EXPORT virtual bool isLoadByDemand(const std::string theDocID);
+  MODEL_EXPORT virtual bool isLoadByDemand(const std::string theDocID, const int theDocIndex);
 
   /// Registers the plugin that creates features.
   /// It is obligatory for each plugin to call this function on loading to be found by
index 21fe583dba774b6a3d0c5cfe4459d24ccad40d81..7b2d7dd1b3887ba6af2b01a53b91721309aed9e5 100644 (file)
@@ -112,7 +112,7 @@ class MODELAPI_EXPORT ModelAPI_Session
   virtual std::list<std::shared_ptr<ModelAPI_Document> > allOpenedDocuments() = 0;
 
   /// Returns true if document is not loaded yet
-  virtual bool isLoadByDemand(const std::string theDocID) = 0;
+  virtual bool isLoadByDemand(const std::string theDocID, const int theDocIndex) = 0;
 
   /// Copies the document to the new one with the given id
   virtual std::shared_ptr<ModelAPI_Document> copy(
index 8ec96b44904ef820b1a998f813823f03148b4c47..4eee01130ea56cad1a35f415f88a224171b7bc55 100644 (file)
@@ -42,7 +42,9 @@ void PartSetPlugin_Part::execute()
     setResult(aResult);
     // do not activate part by simple execution if it is not loaded yet: it must be explicitly
     // activated for this
-    if (!ModelAPI_Session::get()->isLoadByDemand(aResult->data()->name())) {
+    std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef =
+      aResult->data()->document(ModelAPI_ResultPart::DOC_REF());
+    if (!ModelAPI_Session::get()->isLoadByDemand(aResult->data()->name(), aDocRef->docId())) {
       // On undo/redo creation of the part result the Object Browser must get creation event
       // earlier that activation of this part event (otherwise the crash is produced)
       // So, send a creation event earlier, without any grouping