diff options
Diffstat (limited to 'src/Authoring/Client/Code/Core/Commands')
4 files changed, 23 insertions, 44 deletions
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp index 1e521df8..47a44b51 100644 --- a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp +++ b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.cpp @@ -64,9 +64,8 @@ void SApplicationState::Notify(const SApplicationState &inOther, CDoc &inDoc) // to a deleted item void SApplicationState::PreNotify(const SApplicationState &inOther, CDoc &inDoc) { - if (m_SelectedInstance != inOther.m_SelectedInstance) { + if (m_SelectedInstance != inOther.m_SelectedInstance) inDoc.DeselectAllItems(false); - } } CmdDataModel::CmdDataModel(CDoc &inDoc) @@ -96,25 +95,11 @@ bool CmdDataModel::ConsumerExists() const return m_Consumer != nullptr; } -void CmdDataModel::SetConsumer(ITransactionProducer *inProducer) -{ - if (!ConsumerExists()) - m_Consumer = std::make_shared<CTransactionConsumer>(); - inProducer->SetConsumer(m_Consumer); -} - -void CmdDataModel::ReleaseConsumer(ITransactionProducer *inProducer, bool inRunNotifications) -{ - inProducer->SetConsumer(TTransactionConsumerPtr()); - if (inRunNotifications) - RunDoNotifications(); -} - void CmdDataModel::SetConsumer() { if (!ConsumerExists()) { - m_Doc.GetCore()->GetDispatch(); - SetConsumer(m_Doc.GetStudioSystem()); + m_Consumer = std::make_shared<CTransactionConsumer>(); + m_Doc.GetStudioSystem()->SetConsumer(m_Consumer); m_Doc.GetAssetGraph()->SetConsumer(m_Consumer); m_BeforeDoAppState.Store(m_Doc); } @@ -123,11 +108,16 @@ void CmdDataModel::SetConsumer() void CmdDataModel::ReleaseConsumer(bool inRunNotifications) { if (ConsumerExists()) { - m_Doc.GetAssetGraph()->SetConsumer(TTransactionConsumerPtr()); + m_Doc.GetAssetGraph()->SetConsumer(nullptr); + if (HasTransactions()) m_Doc.SetModifiedFlag(true); m_AfterDoAppState.Store(m_Doc); - ReleaseConsumer(m_Doc.GetStudioSystem(), inRunNotifications); + + m_Doc.GetStudioSystem()->SetConsumer(nullptr); + + if (inRunNotifications) + RunDoNotifications(); } } diff --git a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.h b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.h index 7d601826..8bd8621f 100644 --- a/src/Authoring/Client/Code/Core/Commands/CmdDataModel.h +++ b/src/Authoring/Client/Code/Core/Commands/CmdDataModel.h @@ -87,10 +87,6 @@ protected: SApplicationState m_BeforeDoAppState; // The application state after this command. SApplicationState m_AfterDoAppState; - -private: - void SetConsumer(ITransactionProducer *inProducer); - void ReleaseConsumer(ITransactionProducer *inProducer, bool inRunNotifications); }; struct SScopedDataModelConsumer diff --git a/src/Authoring/Client/Code/Core/Commands/CmdStack.cpp b/src/Authoring/Client/Code/Core/Commands/CmdStack.cpp index 3530822f..76f51126 100644 --- a/src/Authoring/Client/Code/Core/Commands/CmdStack.cpp +++ b/src/Authoring/Client/Code/Core/Commands/CmdStack.cpp @@ -27,16 +27,13 @@ ** ****************************************************************************/ -#include "Qt3DSCommonPrecompile.h" #include "CmdStack.h" #include "Cmd.h" #include "CmdStackModifier.h" CCmdStack::CCmdStack() { - m_Listener = NULL; - m_MaxUndoStackSize = 100; - m_CommandStackModifier = NULL; + } CCmdStack::~CCmdStack() @@ -66,14 +63,13 @@ bool CCmdStack::ExecuteCommand(CCmd *inCommand) // Execute the command. unsigned long theUpdateMask = inCommand->Do(); - // If the listener is not null then do the notifications. - if (m_Listener != NULL) { + if (m_Listener) { m_Listener->CommandUpdate(theUpdateMask); // Set the modified flag if it needs to be set. if (inCommand->ShouldSetModifiedFlag()) { - m_Listener->SetCommandModifiedFlag(TRUE); + m_Listener->SetCommandModifiedFlag(true); } } @@ -135,11 +131,11 @@ bool CCmdStack::ExecuteCommand(CCmd *inCommand) //============================================================================= void CCmdStack::Undo() { - if (m_CommandStackModifier) { if (m_CommandStackModifier->PreUndo() == false) return; } + if (m_UndoList.size() > 0) { m_undoingOrRedoing = true; CCmd *theLastCommand = m_UndoList.back(); @@ -147,7 +143,6 @@ void CCmdStack::Undo() unsigned long theUpdateMask = theLastCommand->Undo(); - // Once a command is undone then it is considered committed. Prevents merging after this has // been redone. theLastCommand->SetCommitted(true); @@ -155,13 +150,12 @@ void CCmdStack::Undo() m_RedoList.push_back(theLastCommand); // If the listener is not null then do the notifications. - if (m_Listener != NULL) { + if (m_Listener) { m_Listener->CommandUpdate(theUpdateMask); // Set the modified flag if it needs to be set. - if (theLastCommand->ShouldSetModifiedFlag()) { - m_Listener->SetCommandModifiedFlag(TRUE); - } + if (theLastCommand->ShouldSetModifiedFlag()) + m_Listener->SetCommandModifiedFlag(true); } m_undoingOrRedoing = false; } @@ -186,13 +180,12 @@ void CCmdStack::Redo() m_UndoList.push_back(theLastCommand); // If the listener is not null then do the notifications. - if (m_Listener != NULL) { + if (m_Listener) { m_Listener->CommandUpdate(theUpdateMask); // Set the modified flag if it needs to be set. - if (theLastCommand->ShouldSetModifiedFlag()) { - m_Listener->SetCommandModifiedFlag(TRUE); - } + if (theLastCommand->ShouldSetModifiedFlag()) + m_Listener->SetCommandModifiedFlag(true); } m_undoingOrRedoing = false; } diff --git a/src/Authoring/Client/Code/Core/Commands/CmdStack.h b/src/Authoring/Client/Code/Core/Commands/CmdStack.h index 7388703d..9597f5a6 100644 --- a/src/Authoring/Client/Code/Core/Commands/CmdStack.h +++ b/src/Authoring/Client/Code/Core/Commands/CmdStack.h @@ -102,15 +102,15 @@ public: protected: void EmptyUndoStack(); - ICmdStackModifier *m_CommandStackModifier; + ICmdStackModifier *m_CommandStackModifier = nullptr; TCmdList m_UndoList; TCmdList m_RedoList; bool m_undoingOrRedoing = false; - unsigned long m_MaxUndoStackSize; + unsigned long m_MaxUndoStackSize = 100; - CModificationListener *m_Listener; + CModificationListener *m_Listener = nullptr; }; #endif // INCLUDED_CMD_STACK_H |