From: mpv Date: Mon, 13 Apr 2015 06:11:07 +0000 (+0300) Subject: Make checking type of the asking document to avoid undo/redo of not-current document... X-Git-Tag: V_1.1.0~46^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=caaf3d592b637efa8ad5183b86234ffe59aaa82d;p=modules%2Fshaper.git Make checking type of the asking document to avoid undo/redo of not-current document error message. --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 5ac695f1d..00531ba84 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -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(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(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(); diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 8dcd0a11b..69c2f1b16 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -131,10 +131,10 @@ std::list 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& 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"); diff --git a/src/Model/Model_Session.h b/src/Model/Model_Session.h index ac1e4e1b0..47e40262e 100644 --- a/src/Model/Model_Session.h +++ b/src/Model/Model_Session.h @@ -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 diff --git a/src/ModelAPI/ModelAPI_Session.h b/src/ModelAPI/ModelAPI_Session.h index 613122a35..5c927e7d3 100644 --- a/src/ModelAPI/ModelAPI_Session.h +++ b/src/ModelAPI/ModelAPI_Session.h @@ -106,12 +106,8 @@ class MODELAPI_EXPORT ModelAPI_Session } protected: - /// Creates the feature object using plugins functionality - virtual std::shared_ptr createFeature(std::string theFeatureID) = 0; /// Sets the session interface implementation (once per application launch) static void setSession(std::shared_ptr theManager); - - friend class Model_Document; }; typedef std::shared_ptr SessionPtr;