diff options
Diffstat (limited to 'src/Authoring/Client/Code/Core')
6 files changed, 30 insertions, 52 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 diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp index 14f0a77a..15240e2a 100644 --- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp +++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp @@ -427,7 +427,7 @@ Q3DStudio::IDocumentEditor &CDoc::OpenTransaction(const QString &inCmdName, cons ++m_TransactionDepth; if (m_TransactionDepth == 1) { assert(!m_OpenTransaction); - m_OpenTransaction = std::make_shared<qt3dsdm::CmdDataModel>(std::ref(*this)); + m_OpenTransaction = std::make_shared<qt3dsdm::CmdDataModel>(*this); m_OpenTransaction->SetName(inCmdName); m_OpenTransaction->SetConsumer(); m_Core->SetCommandStackModifier(this); @@ -442,9 +442,9 @@ Q3DStudio::IDocumentEditor &CDoc::OpenTransaction(const QString &inCmdName, cons qCInfo(qt3ds::TRACE_INFO) << inFile << "(" << inLine << "): Open Transaction: " << inCmdName; - if (!m_SceneEditor) { + if (!m_SceneEditor) m_SceneEditor = Q3DStudio::IInternalDocumentEditor::CreateEditor(*this); - } + return *m_SceneEditor; } @@ -484,9 +484,9 @@ void CDoc::IKnowWhatIAmDoingForceCloseTransaction() qCInfo(qt3ds::TRACE_INFO) << "Closing transaction"; // Ensure hasTransaction will return false right at this second. std::shared_ptr<qt3dsdm::CmdDataModel> theTransaction(m_OpenTransaction); - m_OpenTransaction = std::shared_ptr<qt3dsdm::CmdDataModel>(); + m_OpenTransaction.reset(); - m_Core->SetCommandStackModifier(NULL); + m_Core->SetCommandStackModifier(nullptr); // Release the consumer without running notifications because our command will run // the notifications when it first gets executed. theTransaction->ReleaseConsumer(false); @@ -1231,7 +1231,6 @@ void CDoc::OnSlideDeleted(qt3dsdm::Qt3DSDMSlideHandle inSlide) } void CDoc::OnInstanceDeleted(qt3dsdm::Qt3DSDMInstanceHandle inInstance) { - qt3dsdm::TTransactionConsumerPtr theConsumer = m_StudioSystem->GetFullSystem()->GetConsumer(); if (GetSelectedInstance() == inInstance) DeselectAllItems(); @@ -1744,7 +1743,7 @@ void CDoc::CloseDocument() // selection would be invalid from this point onwards DeselectAllItems(); - m_SceneEditor = std::shared_ptr<Q3DStudio::IInternalDocumentEditor>(); + m_SceneEditor.reset(); if (m_DocumentBufferCache) { // Ensure old buffers aren't picked up for the same relative path. m_DocumentBufferCache->Clear(); diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp index 3171f50c..d7cdfb73 100644 --- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp +++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp @@ -5703,5 +5703,5 @@ void CUpdateableDocumentEditor::RollbackEditor() std::shared_ptr<IInternalDocumentEditor> IInternalDocumentEditor::CreateEditor(CDoc &doc) { - return std::shared_ptr<IInternalDocumentEditor>(new CDocEditor(doc)); + return std::make_shared<CDocEditor>(doc); } |