From: mpv Date: Thu, 22 May 2014 14:09:36 +0000 (+0400) Subject: Checking of modifications outside of the transaction X-Git-Tag: V_0.2~26^2~1^2^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=73def5b80ec6240518beacea21ffb82dc9683fd5;p=modules%2Fshaper.git Checking of modifications outside of the transaction --- diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index e6c5c02f2..03effc8e3 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -12,6 +12,8 @@ #include #include #include +#include "Model_Events.h" +#include using namespace std; @@ -35,6 +37,9 @@ string Model_Data::getName() void Model_Data::setName(string theName) { TDataStd_Name::Set(myLab, theName.c_str()); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); + Model_FeatureUpdatedMessage aMsg(myFeature, anEvent); + Events_Loop::loop()->send(aMsg, false); } void Model_Data::addAttribute(string theID, string theAttrType) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 67953331d..662374984 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -594,6 +594,10 @@ void Model_Document::synchronizeFeatures() } } // after all updates, sends a message that groups of features were created or updated + boost::static_pointer_cast(Model_PluginManager::get())-> + setCheckTransactions(false); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED)); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_DELETED)); + boost::static_pointer_cast(Model_PluginManager::get())-> + setCheckTransactions(true); } diff --git a/src/Model/Model_Object.cpp b/src/Model/Model_Object.cpp index 9b39c6d2f..c8a852b51 100644 --- a/src/Model/Model_Object.cpp +++ b/src/Model/Model_Object.cpp @@ -4,6 +4,8 @@ #include "Model_Object.h" #include +#include "Model_Events.h" +#include boost::shared_ptr Model_Object::featureRef() { @@ -17,7 +19,12 @@ std::string Model_Object::getName() void Model_Object::setName(std::string theName) { - myName->Set(theName.c_str()); + if (myName->Get() != theName.c_str()) { + myName->Set(theName.c_str()); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); + Model_FeatureUpdatedMessage aMsg(boost::shared_ptr(this), anEvent); + Events_Loop::loop()->send(aMsg, false); + } } Model_Object::Model_Object(boost::shared_ptr theRef, diff --git a/src/Model/Model_PluginManager.cpp b/src/Model/Model_PluginManager.cpp index 05f1586e6..1a6cef9d8 100644 --- a/src/Model/Model_PluginManager.cpp +++ b/src/Model/Model_PluginManager.cpp @@ -98,6 +98,7 @@ boost::shared_ptr Model_PluginManager::copy( Model_PluginManager::Model_PluginManager() { myPluginsInfoLoaded = false; + myCheckTransactions = true; ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr(this)); // register the configuration reading listener Events_Loop* aLoop = Events_Loop::loop(); @@ -123,7 +124,7 @@ void Model_PluginManager::processEvent(const Events_Message* theMessage) // plugins information was started to load, so, it will be loaded myPluginsInfoLoaded = true; } else { // create/update/delete - if (!rootDocument()->isOperation()) + if (myCheckTransactions && !rootDocument()->isOperation()) Events_Error::send("Modification of data structure outside of the transaction"); } } diff --git a/src/Model/Model_PluginManager.h b/src/Model/Model_PluginManager.h index aa230700a..4efef6a4c 100644 --- a/src/Model/Model_PluginManager.h +++ b/src/Model/Model_PluginManager.h @@ -26,6 +26,7 @@ class Model_PluginManager : public ModelAPI_PluginManager, public Events_Listene std::map myPluginObjs; ///< instances of the already plugins std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently boost::shared_ptr myCurrentDoc; ///< current working document + bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction public: /// Returns the root document of the application (that may contains sub-documents) MODEL_EXPORT virtual boost::shared_ptr rootDocument(); @@ -51,6 +52,8 @@ public: MODEL_EXPORT virtual boost::shared_ptr copy( boost::shared_ptr theSource, std::string theID); + void setCheckTransactions(const bool theCheck) {myCheckTransactions = theCheck;} + /// Is called only once, on startup of the application Model_PluginManager();