summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJere Tuliniemi <jere.tuliniemi@qt.io>2018-12-03 15:41:01 +0200
committerJere Tuliniemi <jere.tuliniemi@qt.io>2018-12-03 15:25:48 +0000
commitf45720e80034b13f98ae3e65c86bb032940a4a3d (patch)
treea28d8bc5443670e6a4025516ae6b4268d1d40eb4
parent3e6334b63bb97d97012a1684b5142da2093f945a (diff)
Fix property state after undoing shader selection
After setting a new shader, setPropertyValues would set the default values again to the material. These values would remain with the instance after an undo and would make the presentation unsaveable. This change makes it so that the default values are not set again. Task-number: QT3DS-2796 Change-Id: I2fa95e29b9f20da6a00ce71a81e3dd6956e7206b Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
index e4c9c6ef..9663f920 100644
--- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
+++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp
@@ -2372,6 +2372,14 @@ public:
TInstanceHandle handle;
};
+ void setInstanceValueIfChanged(TInstanceHandle instance, TPropertyHandle prop, SValue value)
+ {
+ SValue oldValue;
+ m_PropertySystem.GetInstancePropertyValue(instance, prop, oldValue);
+ if (oldValue != value)
+ SetInstancePropertyValue(instance, prop, value);
+ }
+
QVector<ChildInstance> setPropertyValues(TInstanceHandle instance,
const QMap<QString, QString> &values)
{
@@ -2396,8 +2404,7 @@ public:
switch (type) {
case DataModelDataType::Long4:
{
- SetInstancePropertyValue(instance, prop,
- std::make_shared<CDataStr>(propString));
+ setInstanceValueIfChanged(instance, prop, std::make_shared<CDataStr>(propString));
SValue value;
m_PropertySystem.GetInstancePropertyValue(instance, prop, value);
if (!value.empty()) {
@@ -2412,7 +2419,7 @@ public:
}
case DataModelDataType::Float:
{
- SetInstancePropertyValue(instance, prop, i.value().toFloat());
+ setInstanceValueIfChanged(instance, prop, i.value().toFloat());
break;
}
case DataModelDataType::Float2:
@@ -2420,7 +2427,7 @@ public:
QStringList floats = i.value().split(QStringLiteral(" "));
if (floats.length() == 2) {
SFloat2 value(floats[0].toFloat(), floats[1].toFloat());
- SetInstancePropertyValue(instance, prop, value);
+ setInstanceValueIfChanged(instance, prop, value);
}
break;
}
@@ -2429,21 +2436,21 @@ public:
QStringList floats = i.value().split(QStringLiteral(" "));
if (floats.length() == 3) {
SFloat3 value(floats[0].toFloat(), floats[1].toFloat(), floats[2].toFloat());
- SetInstancePropertyValue(instance, prop, value);
+ setInstanceValueIfChanged(instance, prop, value);
}
break;
}
case DataModelDataType::Bool:
{
if (propString == "True")
- SetInstancePropertyValue(instance, prop, true);
+ setInstanceValueIfChanged(instance, prop, true);
else if (propString == "False")
- SetInstancePropertyValue(instance, prop, false);
+ setInstanceValueIfChanged(instance, prop, false);
break;
}
case DataModelDataType::String:
{
- SetInstancePropertyValue(instance, prop, std::make_shared<CDataStr>(propString));
+ setInstanceValueIfChanged(instance, prop, std::make_shared<CDataStr>(propString));
break;
}
default: