diff options
author | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2019-10-14 13:49:37 +0300 |
---|---|---|
committer | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2019-10-14 14:33:05 +0300 |
commit | bcc438c1b268678c93f8fb6a1eea6392709677fe (patch) | |
tree | 96237201a15f5d4f5bcdc3fd606740afbc392c89 | |
parent | efb19fb7e16bdebe9e3db792dd9eb285be982644 (diff) |
Retain file id when changing material type
Custom shaders would copy the class file id to be the object file id,
causing duplicate id errors upon saving. This is fixed by restoring the
old file id after changing the material type.
Task-number: QT3DS-3976
Change-Id: I2073fd6d7cc0bfbbd0e52ff6ab9b7d51206d7638
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r-- | src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp index dc60eeb4..218cdcd7 100644 --- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp +++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp @@ -1855,6 +1855,7 @@ public: // Keep material names the same so that if you change the material type // any relative path links will still work. // Next bug is harder (keep id's the same). + Q3DStudio::CString fileId = GetFileId(instance); Q3DStudio::CString theName = GetName(instance); SLong4 theGuid = m_Bridge.GetInstanceGUID(instance); TInstanceHandle nextChild = m_AssetGraph.GetSibling(instance, true); @@ -1914,6 +1915,9 @@ public: m_Bridge.GetObjectDefinitions().m_Lightmaps.m_LightmapShadow, theLightmapShadowValue, false); + m_DataCore.SetInstancePropertyValue(newMaterial, + m_Bridge.GetObjectDefinitions().m_Asset.m_FileId, + std::make_shared<CDataStr>(fileId.c_str())); SetName(newMaterial, theName, false); m_Bridge.SetInstanceGUID(newMaterial, theGuid); // Copy all actions from old material instance to new material instance |