diff options
author | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2018-12-03 15:54:22 +0200 |
---|---|---|
committer | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2018-12-03 15:25:59 +0000 |
commit | 2ba5f4d873a1fb04b891238f78868778fd4bc20f (patch) | |
tree | b6da3f9730fcc1600664b5e189ed4c62d9704ee7 | |
parent | 5a476f2d888aab2eb4a5c847af6be3d4e1cca727 (diff) |
Ignore matdef changes triggered by the editor
After the editor saves a materialdef file, the editor doesn't need to
react to that change.
Change-Id: I4fa5fd79536388450ccb39d2ff55eab53f11a04b
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
3 files changed, 25 insertions, 3 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp index 3171f50c..20cb4428 100644 --- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp +++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp @@ -171,6 +171,7 @@ class CDocEditor : public Q3DStudio::IInternalDocumentEditor Q3DStudio::Foundation::SStudioFoundation m_Foundation; TStreamFactoryPtr m_InputStreamFactory; std::unordered_map<long, QT3DSU32> m_GraphOrderMap; + bool m_ignoreNextMaterialDefChange = false; public: CDocEditor(CDoc &inDoc) @@ -2037,8 +2038,11 @@ public: fileInfo.dir().mkpath(QStringLiteral(".")); QFile file(actualSourcePath); - if ((createNewFile && !file.exists()) || (!createNewFile && file.exists())) + if ((createNewFile && !file.exists()) || (!createNewFile && file.exists())) { + if (!createNewFile) + m_ignoreNextMaterialDefChange = true; saveMaterial(instance, file); + } return m_Doc.GetRelativePathToDoc(actualSourcePath); } @@ -2112,6 +2116,16 @@ public: writeMaterialFile(material, false); } + bool isIgnoringNextMaterialDefChange() override + { + return m_ignoreNextMaterialDefChange; + } + + void stopIgnoringNextMaterialDefChange() override + { + m_ignoreNextMaterialDefChange = false; + } + void saveMaterial(Qt3DSDMInstanceHandle instance, QFile &file) { SValue value; diff --git a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h index 9319808f..4fb5d5e0 100644 --- a/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h +++ b/src/Authoring/Client/Code/Core/Doc/IDocumentEditor.h @@ -181,6 +181,9 @@ public: virtual QString getMaterialDirectoryPath() const = 0; virtual QString getMaterialFilePath(const QString &materialName) const = 0; + virtual bool isIgnoringNextMaterialDefChange() = 0; + virtual void stopIgnoringNextMaterialDefChange() = 0; + virtual void saveIfMaterial(Qt3DSDMInstanceHandle instance) = 0; virtual void writeMaterialFile(Qt3DSDMInstanceHandle instance, bool createNewFile) = 0; virtual Q3DStudio::CString writeMaterialFile(Qt3DSDMInstanceHandle instance, diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp index 33ca1461..c593dea1 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp @@ -511,14 +511,19 @@ void InspectorControlModel::setMaterials(std::vector<Q3DStudio::CFilePath> &mate void InspectorControlModel::setMatDatas(const std::vector<Q3DStudio::CFilePath> &matDatas) { - m_matDatas.clear(); - const auto doc = g_StudioApp.GetCore()->GetDoc(); bool isDocModified = doc->IsModified(); const auto sceneEditor = doc->getSceneEditor(); if (!sceneEditor) return; + if (sceneEditor->isIgnoringNextMaterialDefChange()) { + sceneEditor->stopIgnoringNextMaterialDefChange(); + return; + } + + m_matDatas.clear(); + bool newMaterialSelected = false; for (const Q3DStudio::CFilePath &path : matDatas) { bool isNewFile = true; |