]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make checking type of the asking document to avoid undo/redo of not-current document...
authormpv <mpv@opencascade.com>
Mon, 13 Apr 2015 06:11:07 +0000 (09:11 +0300)
committermpv <mpv@opencascade.com>
Mon, 13 Apr 2015 06:11:07 +0000 (09:11 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Session.cpp
src/Model/Model_Session.h
src/ModelAPI/ModelAPI_Session.h

index 5ac695f1d094c93722b2c96e84992315c2bdcb76..00531ba8445b1ff25404cbee87f8ca7c3cf03ad5 100644 (file)
@@ -557,7 +557,8 @@ FeaturePtr Model_Document::addFeature(std::string theID)
 {
   TDF_Label anEmptyLab;
   FeaturePtr anEmptyFeature;
-  FeaturePtr aFeature = ModelAPI_Session::get()->createFeature(theID);
+  FeaturePtr aFeature = 
+    std::dynamic_pointer_cast<Model_Session>(ModelAPI_Session::get())->createFeature(theID, this);
   if (!aFeature)
     return aFeature;
   Model_Document* aDocToAdd;
@@ -985,9 +986,9 @@ void Model_Document::synchronizeFeatures(
     FeaturePtr aFeature;
     if (!myObjs.IsBound(aFeatureLabel)) {  // a new feature is inserted
       // create a feature
-      aFeature = ModelAPI_Session::get()->createFeature(
+      aFeature = std::dynamic_pointer_cast<Model_Session>(ModelAPI_Session::get())->createFeature(
         TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get())
-        .ToCString());
+        .ToCString(), this);
       if (!aFeature) {  // somethig is wrong, most probably, the opened document has invalid structure
         Events_Error::send("Invalid type of object in the document");
         aLabIter.Value()->Label().ForgetAllAttributes();
index 8dcd0a11b0e04e008fc17b0d4f906fb9058be13e..69c2f1b162d5421345e41028f8f37e41a676688f 100644 (file)
@@ -131,10 +131,10 @@ std::list<std::string> Model_Session::redoList()
   return ROOT_DOC->redoList();
 }
 
-FeaturePtr Model_Session::createFeature(string theFeatureID)
+FeaturePtr Model_Session::createFeature(string theFeatureID, Model_Document* theDocOwner)
 {
   if (this != myImpl) {
-    return myImpl->createFeature(theFeatureID);
+    return myImpl->createFeature(theFeatureID, theDocOwner);
   }
 
   // load all information about plugins, features and attributes
@@ -142,7 +142,7 @@ FeaturePtr Model_Session::createFeature(string theFeatureID)
 
   if (myPlugins.find(theFeatureID) != myPlugins.end()) {
     std::pair<std::string, std::string>& aPlugin = myPlugins[theFeatureID]; // plugin and doc kind
-    if (!aPlugin.second.empty() && aPlugin.second != activeDocument()->kind()) {
+    if (!aPlugin.second.empty() && aPlugin.second != theDocOwner->kind()) {
       Events_Error::send(
           string("Feature '") + theFeatureID + "' can be created only in document '"
               + aPlugin.second + "' by the XML definition");
index ac1e4e1b0e3f3b5f0d182233b9a7622f86a3d62a..47e40262e3ae4cab165f84103d1467b9856724da 100644 (file)
@@ -119,7 +119,9 @@ class Model_Session : public ModelAPI_Session, public Events_Listener
   void LoadPluginsInfo();
 
   /// Creates the feature object using plugins functionality
-  virtual FeaturePtr createFeature(std::string theFeatureID);
+  FeaturePtr createFeature(std::string theFeatureID, Model_Document* theDocOwner);
+
+  friend class Model_Document;
 };
 
 #endif
index 613122a35a7e01ae0dbb312770127cce08926d5d..5c927e7d3eec56226d1b56c43e9e9cbe23acf550 100644 (file)
@@ -106,12 +106,8 @@ class MODELAPI_EXPORT ModelAPI_Session
   }
 
  protected:
-  /// Creates the feature object using plugins functionality
-  virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
   /// Sets the session interface implementation (once per application launch)
   static void setSession(std::shared_ptr<ModelAPI_Session> theManager);
-
-  friend class Model_Document;
 };
 
 typedef std::shared_ptr<ModelAPI_Session> SessionPtr;