summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Client
diff options
context:
space:
mode:
authorJere Tuliniemi <jere.tuliniemi@qt.io>2018-11-22 17:52:30 +0200
committerJere Tuliniemi <jere.tuliniemi@qt.io>2018-11-26 13:08:28 +0000
commit06498355471227722dcf9be936776f6dcb5a1e04 (patch)
treedc5eca7afa661664ad11f98bc5dd584caabe4be5 /src/Authoring/Client
parent42e56b5a07976cd24e9eb764fc498dc99f7c3b3d (diff)
Fix undo and redo matdef saving
Task-number: QT3DS-2706 Change-Id: I797d615df13029bf062b5437ac588dbc5c77324b Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Client')
-rw-r--r--src/Authoring/Client/Code/Core/Commands/CmdStack.cpp9
-rw-r--r--src/Authoring/Client/Code/Core/Commands/CmdStack.h4
-rw-r--r--src/Authoring/Client/Code/Core/Doc/Doc.cpp6
3 files changed, 18 insertions, 1 deletions
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdStack.cpp b/src/Authoring/Client/Code/Core/Commands/CmdStack.cpp
index c6aa0882..3530822f 100644
--- a/src/Authoring/Client/Code/Core/Commands/CmdStack.cpp
+++ b/src/Authoring/Client/Code/Core/Commands/CmdStack.cpp
@@ -141,6 +141,7 @@ void CCmdStack::Undo()
return;
}
if (m_UndoList.size() > 0) {
+ m_undoingOrRedoing = true;
CCmd *theLastCommand = m_UndoList.back();
m_UndoList.pop_back();
@@ -162,6 +163,7 @@ void CCmdStack::Undo()
m_Listener->SetCommandModifiedFlag(TRUE);
}
}
+ m_undoingOrRedoing = false;
}
}
@@ -175,6 +177,7 @@ void CCmdStack::Undo()
void CCmdStack::Redo()
{
if (m_RedoList.size() > 0) {
+ m_undoingOrRedoing = true;
CCmd *theLastCommand = m_RedoList.back();
m_RedoList.pop_back();
@@ -191,6 +194,7 @@ void CCmdStack::Redo()
m_Listener->SetCommandModifiedFlag(TRUE);
}
}
+ m_undoingOrRedoing = false;
}
}
@@ -216,6 +220,11 @@ bool CCmdStack::CanRedo()
return m_RedoList.size() > 0;
}
+bool CCmdStack::isUndoingOrRedoing() const
+{
+ return m_undoingOrRedoing;
+}
+
//=============================================================================
/**
* Remove the last command from the undo list
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdStack.h b/src/Authoring/Client/Code/Core/Commands/CmdStack.h
index 4aabd228..7388703d 100644
--- a/src/Authoring/Client/Code/Core/Commands/CmdStack.h
+++ b/src/Authoring/Client/Code/Core/Commands/CmdStack.h
@@ -80,6 +80,8 @@ public:
bool CanUndo();
bool CanRedo();
+ bool isUndoingOrRedoing() const;
+
void RemoveLastUndo();
QString GetUndoDescription();
@@ -105,6 +107,8 @@ protected:
TCmdList m_UndoList;
TCmdList m_RedoList;
+ bool m_undoingOrRedoing = false;
+
unsigned long m_MaxUndoStackSize;
CModificationListener *m_Listener;
diff --git a/src/Authoring/Client/Code/Core/Doc/Doc.cpp b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
index b632513d..3457d50a 100644
--- a/src/Authoring/Client/Code/Core/Doc/Doc.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/Doc.cpp
@@ -1275,7 +1275,11 @@ void CDoc::onPropertyChanged(qt3dsdm::Qt3DSDMInstanceHandle inInstance,
qt3dsdm::Qt3DSDMPropertyHandle inProperty)
{
using namespace qt3dsdm;
-
+ // Save the material definition upon undo and redo
+ if (m_Core->GetCmdStack()->isUndoingOrRedoing() &&
+ m_StudioSystem->GetClientDataModelBridge()->isInsideMaterialContainer(inInstance)) {
+ getSceneEditor()->saveIfMaterial(inInstance);
+ }
// check if we changed datainput bindings
if (inProperty == m_StudioSystem->GetPropertySystem()
->GetAggregateInstancePropertyByName(inInstance, L"controlledproperty")) {