summaryrefslogtreecommitdiffstats
path: root/src/Authoring
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2020-10-12 10:39:54 +0300
committerAntti Määttä <antti.maatta@qt.io>2020-10-15 12:12:06 +0300
commitd67bb6e4ecabd769b36269e116b1e0525a8a07e2 (patch)
tree743b656a0e521b36f31a5c99a7d6b1d108c5dadf /src/Authoring
parent93c8683d4ec97161c30a314e0f5508c83f3dcf00 (diff)
Fix crash and assertions
Fix crash when deleting custom material immediately after creating it. Fix assertions from getting incorrect datatype. Change-Id: I020b8397de13fb88f594fe85ec1da66dd999f97b Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src/Authoring')
-rw-r--r--src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp7
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp14
-rw-r--r--src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp2
3 files changed, 16 insertions, 7 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp
index ab0cdc9f..9d7837f6 100644
--- a/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/ClientDataModelBridge/ClientDataModelBridge.cpp
@@ -592,7 +592,7 @@ bool CClientDataModelBridge::GetMaterialFromImageInstance(
qt3dsdm::Qt3DSDMInstanceHandle theInstance = iter->second.first;
qt3dsdm::Qt3DSDMPropertyHandle theProperty = iter->second.second;
SValue value = GetInstancePropertyValue(thePropertySystem, theInstance, theProperty);
- if (!value.empty()) {
+ if (!value.empty() && value.getType() == qt3dsdm::DataModelDataType::Long4) {
SLong4 theLong4PropertyValue = value.getData<SLong4>();
if (theLong4PropertyValue == theDeletedImageLong4) {
outMaterialInstance = theInstance;
@@ -654,9 +654,10 @@ bool CClientDataModelBridge::GetMaterialFromImageInstance(
if (theAdditionalMetaDataType == AdditionalMetaDataType::Image
|| theAdditionalMetaDataType == AdditionalMetaDataType::Texture) {
- SLong4 theLong4PropertyValue = GetSpecificInstancePropertyValue<SLong4>(
+ SValue propertyValue = GetInstancePropertyValue(
thePropertySystem, theInstance, theProperty);
- if (theDeletedImageLong4 == theLong4PropertyValue) {
+ if (propertyValue.getType() == qt3dsdm::DataModelDataType::Long4
+ && theDeletedImageLong4 == propertyValue.getData<SLong4>()) {
outMaterialInstance = theInstance;
outProperty = theProperty;
m_cachedImageParents.insert({inInstance,
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index 60cc6dfb..02d7a3a1 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -292,7 +292,8 @@ public:
if (m_SlideCore.GetSpecificInstancePropertyValue(theAssociatedSlide, instance, inProperty,
theGuid)
|| m_DataCore.GetInstancePropertyValue(instance, inProperty, theGuid)) {
- return m_Bridge.GetInstanceByGUID(get<SLong4>(theGuid));
+ if (theGuid.getType() == qt3dsdm::DataModelDataType::Long4)
+ return m_Bridge.GetInstanceByGUID(get<SLong4>(theGuid));
}
return TInstanceHandle();
}
@@ -1182,8 +1183,15 @@ public:
if (!m_Bridge.GetMaterialFromImageInstance(instance, theParent, theProperty))
m_Bridge.GetLayerFromImageProbeInstance(instance, theParent, theProperty);
- if (theParent.Valid())
- m_PropertySystem.SetInstancePropertyValue(theParent, theProperty, SLong4());
+ if (theParent.Valid()) {
+ auto type = m_PropertySystem.GetAdditionalMetaDataType(theParent, theProperty);
+ if (type == AdditionalMetaDataType::Image) {
+ m_PropertySystem.SetInstancePropertyValue(theParent, theProperty, SLong4());
+ } else if (type == AdditionalMetaDataType::Texture) {
+ m_PropertySystem.SetInstancePropertyValue(theParent, theProperty,
+ std::make_shared<CDataStr>(Q3DStudio::CString()));
+ }
+ }
} else if (m_Bridge.IsBehaviorInstance(instance) || m_Bridge.IsEffectInstance(instance)
|| m_Bridge.IsCustomMaterialInstance(instance)) {
// Check if this is the last instance that uses the same sourcepath property
diff --git a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp
index 599b2a9f..283f98e5 100644
--- a/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp
+++ b/src/Authoring/Qt3DStudio/Palettes/Timeline/Bindings/MaterialTimelineItemBinding.cpp
@@ -97,7 +97,7 @@ bool ImageSlotIsFilled(qt3dsdm::IPropertySystem *inPropertySystem, Qt3DSDMInstan
inPropertySystem->GetInstancePropertyValue(inInstance, theProperty, theValue);
// Prevent assertion down the path when changing from edited standard material to reference material
- if (qt3dsdm::GetValueType(theValue) == DataModelDataType::None)
+ if (qt3dsdm::GetValueType(theValue) != DataModelDataType::Long4)
return false;
SLong4 theLong4 = qt3dsdm::get<SLong4>(theValue);