X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Session.cpp;h=2a830e788a740f3414a5ad29d9de423470f07db3;hb=b73fb7468bea81901dbeed8e229d742f788ec282;hp=07f3e98f042f5e1364caa5e4a76419d874ddbc6a;hpb=36063c8969dc4067cda6196c2d3abba7e9ed3af9;p=modules%2Fshaper.git diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 07f3e98f0..2a830e788 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -424,7 +424,6 @@ Model_Session::Model_Session() myPluginsInfoLoaded = false; myCheckTransactions = true; myOperationAttachedToNext = false; - myIsAutoUpdateBlocked = false; ModelAPI_Session::setSession(std::shared_ptr(this)); // register the configuration reading listener Events_Loop* aLoop = Events_Loop::loop(); @@ -579,19 +578,41 @@ int Model_Session::transactionID() return ROOT_DOC->transactionID(); } +bool Model_Session::isAutoUpdateBlocked() +{ + Handle(Model_Application) anApp = Model_Application::getApplication(); + if (!anApp->hasRoot()) // when document is not yet created, do not create it by such simple call + return false; + return !ROOT_DOC->autoRecomutationState(); +} + void Model_Session::blockAutoUpdate(const bool theBlock) { - if (myIsAutoUpdateBlocked != theBlock) { - myIsAutoUpdateBlocked = theBlock; + bool aCurrentState = isAutoUpdateBlocked(); + if (aCurrentState != theBlock) { + // if there is no operation, start it to avoid modifications outside of transaction + bool isOperation = this->isOperation(); + if (!isOperation) + startOperation("Auto update"); + ROOT_DOC->setAutoRecomutationState(!theBlock); static Events_Loop* aLoop = Events_Loop::loop(); if (theBlock) { static const Events_ID kAutoOff = aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_DISABLE); std::shared_ptr aMsg(new Events_Message(kAutoOff)); aLoop->send(aMsg); } else { + // if there is no operation, start it to avoid modifications outside of transaction + bool isOperation = this->isOperation(); + if (!isOperation) + startOperation("Auto update enabling"); static const Events_ID kAutoOn = aLoop->eventByName(EVENT_AUTOMATIC_RECOMPUTATION_ENABLE); std::shared_ptr aMsg(new Events_Message(kAutoOn)); aLoop->send(aMsg); } + if (!isOperation) { + finishOperation(); + // append this transaction to the previous one: ne don't need this separated operation in list + ROOT_DOC->appendTransactionToPrevious(); + } } }