From: mpv Date: Fri, 27 Feb 2015 08:34:58 +0000 (+0300) Subject: Fix for issue #409 : skip the current operation in the undo list X-Git-Tag: V_1.1.0~161^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=acdcf4e6e828cc9990e5542557d972d0f8ea3f19;p=modules%2Fshaper.git Fix for issue #409 : skip the current operation in the undo list --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index be3489d7b..32ae61026 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -405,7 +405,7 @@ void Model_Document::abortOperation() subDoc(*aSubIter)->abortOperation(); } -bool Model_Document::isOperation() +bool Model_Document::isOperation() const { // operation is opened for all documents: no need to check subs return myDoc->HasOpenCommand() == Standard_True ; @@ -495,12 +495,15 @@ void Model_Document::redo() std::list Model_Document::undoList() const { std::list aResult; + // the number of skipped current operations (on undo they will be aborted) + int aSkipCurrent = isOperation() ? 1 : 0; std::list::const_reverse_iterator aTrIter = myTransactions.crbegin(); int aNumUndo = myTransactions.size(); if (!myNestedNum.empty()) aNumUndo = *myNestedNum.rbegin(); for( ; aNumUndo > 0; aTrIter++, aNumUndo--) { - aResult.push_back(aTrIter->myId); + if (aSkipCurrent == 0) aResult.push_back(aTrIter->myId); + else aSkipCurrent--; } return aResult; } diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 62bd3ad40..bffcc81bc 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -61,7 +61,7 @@ class Model_Document : public ModelAPI_Document //! Aborts the operation MODEL_EXPORT virtual void abortOperation(); //! Returns true if operation has been started, but not yet finished or aborted - MODEL_EXPORT virtual bool isOperation(); + MODEL_EXPORT virtual bool isOperation() const; //! Returns true if document was modified (since creation/opening) MODEL_EXPORT virtual bool isModified(); diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index f7293bb6d..96395a997 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -141,25 +141,25 @@ public: }; /// Message that document (Part, PartSet) was created -class MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage : public Events_Message +class ModelAPI_DocumentCreatedMessage : public Events_Message { DocumentPtr myDocument; public: /// Creates an empty message - ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0); + MODELAPI_EXPORT ModelAPI_DocumentCreatedMessage(const Events_ID theID, const void* theSender = 0); /// The virtual destructor - virtual ~ModelAPI_DocumentCreatedMessage(); + MODELAPI_EXPORT virtual ~ModelAPI_DocumentCreatedMessage(); - static Events_ID eventId() + MODELAPI_EXPORT static Events_ID eventId() { static const char * MY_DOCUMENT_CREATED_EVENT_ID("DocumentCreated"); return Events_Loop::eventByName(MY_DOCUMENT_CREATED_EVENT_ID); } - DocumentPtr document() const; - void setDocument(DocumentPtr theDocument); + MODELAPI_EXPORT DocumentPtr document() const; + MODELAPI_EXPORT void setDocument(DocumentPtr theDocument); }; #endif