//=================================================================================================
void FeaturesPlugin_CompositeBoolean::erase()
{
- FeaturePtr aSketch =
- std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_OBJECT_ID())->value());
- if (aSketch.get() && aSketch->data()->isValid()) {
- document()->removeFeature(aSketch);
+ if (data().get() && data()->isValid()) { // on abort of sketch of this composite it may be invalid
+ FeaturePtr aSketch =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_OBJECT_ID())->value());
+ if (aSketch.get() && aSketch->data()->isValid()) {
+ document()->removeFeature(aSketch);
+ }
}
ModelAPI_CompositeFeature::erase();
}
Model_Application::getApplication()->deleteAllDocuments();
}
-void Model_Session::startOperation(const std::string& theId)
+void Model_Session::startOperation(const std::string& theId, const bool theAttachedToNested)
{
+ myOperationAttachedToNext = theAttachedToNested;
ROOT_DOC->startOperation();
ROOT_DOC->operationId(theId);
static std::shared_ptr<Events_Message> aStartedMsg
{
setCheckTransactions(false);
ROOT_DOC->finishOperation();
+ if (myOperationAttachedToNext) { // twice, with nested
+ ROOT_DOC->finishOperation();
+ myOperationAttachedToNext = false;
+ }
setCheckTransactions(true);
}
{
setCheckTransactions(false);
ROOT_DOC->abortOperation();
+ if (myOperationAttachedToNext) { // twice, with nested
+ ROOT_DOC->abortOperation();
+ myOperationAttachedToNext = false;
+ }
setCheckTransactions(true);
// here the update mechanism may work after abort, so, supress the warnings about
// modifications outside of the transactions
{
myPluginsInfoLoaded = false;
myCheckTransactions = true;
+ myOperationAttachedToNext = false;
ModelAPI_Session::setSession(std::shared_ptr<ModelAPI_Session>(this));
// register the configuration reading listener
Events_Loop* aLoop = Events_Loop::loop();
std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
std::shared_ptr<ModelAPI_Document> myCurrentDoc; ///< current working document
bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction
+ bool myOperationAttachedToNext; ///< the current operation must be commited twice, with nested
public:
//! Loads the OCAF document from the file.
MODEL_EXPORT virtual void closeAll();
//! Starts a new operation (opens a tansaction)
- MODEL_EXPORT virtual void startOperation(const std::string& theId = "");
+ //! \param theAttachedToNested if it is true, it means that this transaction is attached to the nested
+ //! where it is located and will be commited on the next commit with the nested
+ MODEL_EXPORT virtual void startOperation(
+ const std::string& theId = "", const bool theAttachedToNested = false);
//! Finishes the previously started operation (closes the transaction)
MODEL_EXPORT virtual void finishOperation();
//! Aborts the operation
//! Starts a new operation (opens a tansaction)
//! \param theId of operation for history (optional)
- virtual void startOperation(const std::string& theId = "") = 0;
+ //! \param theAttachedToNested if it is true, it means that this transaction is attached to the nested
+ //! where it is located and will be commited on the next commit with the nested
+ virtual void startOperation(
+ const std::string& theId = "", const bool theAttachedToNested = false) = 0;
//! Finishes the previously started operation (closes the transaction)
virtual void finishOperation() = 0;
//! Aborts the operation
connect(myModule, SIGNAL(operationResumed(ModuleBase_Operation*)), SLOT(onResumed(ModuleBase_Operation*)));
SessionPtr aMgr = ModelAPI_Session::get();
+ // Open transaction that is general for the previous nested one: it will be closed on nested commit
bool aIsOp = aMgr->isOperation();
- // Open transaction if it was closed before
- if (!aIsOp)
- aMgr->startOperation();
+ if (!aIsOp) {
+ const static std::string aNestedOpID("Parameters modification");
+ aMgr->startOperation(aNestedOpID, true);
+ }
restoreValue();
return false;
if (aSketchFeature->numberOfSubs() == 0) {
// Abort operation
SessionPtr aMgr = ModelAPI_Session::get();
- bool aIsOp = aMgr->isOperation();
// Close transaction
- if (aIsOp)
- aMgr->abortOperation();
+ /*
+ bool aIsOp = aMgr->isOperation();
+ if (aIsOp) {
+ const static std::string aNestedOpID("Parameters cancelation");
+ aMgr->startOperation(aNestedOpID, true);
+ }
+ */
theOp->abort();
} else {
// Hide sketcher result