summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2018-11-14 13:40:38 +0200
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2019-03-07 12:42:54 +0000
commita6509c92d61da36819ee44775d291ad1563a53e3 (patch)
tree2d728cb79db2c8056b821bddcee944dc05ce2c29
parentf621c33d5e7f440e3bada49183f3217e89bb5b30 (diff)
Do not cache datainput min/max ranges
Always query datainput range min/max values from the engine level instead of caching the latest value at Q3DSDataInput level. This is to prevent issues with several Q3DSDataInput objects referring to same datainput entry getting out of sync. For QML, change signal is emitted only for local changes, not for changes through other datainput instances. Task-id: QT3DS-3001 Change-Id: I6e17aeca9ddc6ef59a11fb08ea8e33ccf283b743 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> (cherry picked from commit f05671f64981374fb3d4e598db19ce2a3f142f75) Reviewed-by: Christian Strømme <christian.stromme@qt.io>
-rw-r--r--src/runtime/api/q3dsdatainput.cpp56
-rw-r--r--src/runtime/api/q3dsdatainput_p.h8
-rw-r--r--src/runtime/api/q3dspresentation.cpp13
-rw-r--r--src/runtime/api/q3dspresentation_p.h3
-rw-r--r--src/runtime/q3dsengine.cpp11
-rw-r--r--src/runtime/q3dsengine_p.h3
6 files changed, 46 insertions, 48 deletions
diff --git a/src/runtime/api/q3dsdatainput.cpp b/src/runtime/api/q3dsdatainput.cpp
index 5ac2907..2f4a8fb 100644
--- a/src/runtime/api/q3dsdatainput.cpp
+++ b/src/runtime/api/q3dsdatainput.cpp
@@ -64,20 +64,6 @@ Q3DSDataInput::Q3DSDataInput(Q3DSPresentation *presentation, const QString &name
Q_D(Q3DSDataInput);
d->name = name;
d->presentation = presentation;
- // Reach into engine that holds the actual datainput specs
- // derived from presentation/project file at initialization
- if (isValid()) {
- int min = d->getMin();
- if (d->min != min) {
- d->min = min;
- emit minChanged();
- }
- int max = d->getMax();
- if (d->max != max) {
- d->max = max;
- emit maxChanged();
- }
- }
}
/*!
@@ -227,7 +213,7 @@ void Q3DSDataInput::setValue(const QVariant &value)
float Q3DSDataInput::min() const
{
Q_D(const Q3DSDataInput);
- return d->min;
+ return Q3DSPresentationPrivate::get(d->presentation)->dataInputMin(d->name);
}
/*!
@@ -238,8 +224,7 @@ float Q3DSDataInput::min() const
void Q3DSDataInput::setMin(float min)
{
Q_D(Q3DSDataInput);
- d->min = min;
- d->sendMinMax(min, d->max);
+ d->sendMin(min);
emit minChanged();
}
@@ -252,7 +237,7 @@ void Q3DSDataInput::setMin(float min)
float Q3DSDataInput::max() const
{
Q_D(const Q3DSDataInput);
- return d->max;
+ return Q3DSPresentationPrivate::get(d->presentation)->dataInputMax(d->name);
}
/*!
@@ -263,8 +248,7 @@ float Q3DSDataInput::max() const
void Q3DSDataInput::setMax(float max)
{
Q_D(Q3DSDataInput);
- d->max = max;
- d->sendMinMax(d->min, max);
+ d->sendMax(max);
emit maxChanged();
}
@@ -284,28 +268,20 @@ void Q3DSDataInputPrivate::sendValue()
presentation->setDataInputValue(name, value);
}
-void Q3DSDataInputPrivate::sendMinMax(float min, float max)
+void Q3DSDataInputPrivate::sendMin(float min)
{
if (!presentation)
return;
- Q3DSPresentationPrivate::get(presentation)->setDataInputMinMax(name, min, max);
-}
-
-float Q3DSDataInputPrivate::getMin() const
-{
- if (!presentation)
- return 0.0f;
-
- return Q3DSPresentationPrivate::get(presentation)->dataInputMin(name);
+ Q3DSPresentationPrivate::get(presentation)->setDataInputMin(name, min);
}
-float Q3DSDataInputPrivate::getMax() const
+void Q3DSDataInputPrivate::sendMax(float max)
{
if (!presentation)
- return 0.0f;
+ return;
- return Q3DSPresentationPrivate::get(presentation)->dataInputMax(name);
+ Q3DSPresentationPrivate::get(presentation)->setDataInputMax(name, max);
}
/*!
@@ -394,6 +370,13 @@ float Q3DSDataInputPrivate::getMax() const
This property is applicable only to data input type \e {Ranged Number}. For other
types, value returned is zero.
+
+ The value of this property only accounts for changes done via the same
+ DataInput instance. If the value of the property is changed elsewhere,
+ those changes are not reflected in the value of this property.
+ Due to this uncertainty, this property treats all value sets as changes
+ even if the newly set value is the same value as the
+ previous value.
*/
/*!
@@ -403,6 +386,13 @@ float Q3DSDataInputPrivate::getMax() const
This property is applicable only to data input type \e {Ranged Number}. For other
types, value returned is zero.
+
+ The value of this property only accounts for changes done via the same
+ DataInput instance. If the value of the property is changed elsewhere,
+ those changes are not reflected in the value of this property.
+ Due to this uncertainty, this property treats all value sets as changes
+ even if the newly set value is the same value as the
+ previous value.
*/
QT_END_NAMESPACE
diff --git a/src/runtime/api/q3dsdatainput_p.h b/src/runtime/api/q3dsdatainput_p.h
index d3e5144..7dcca9e 100644
--- a/src/runtime/api/q3dsdatainput_p.h
+++ b/src/runtime/api/q3dsdatainput_p.h
@@ -56,17 +56,13 @@ class Q3DSV_PRIVATE_EXPORT Q3DSDataInputPrivate : public QObjectPrivate
public:
static Q3DSDataInputPrivate *get(Q3DSDataInput *p) { return p->d_func(); }
void sendValue();
- void sendMinMax(float min, float max);
+ void sendMin(float min);
+ void sendMax(float min);
void sendMetaData(const QVariant &key, const QVariant &metadata);
QString name;
QVariant value;
- float min = 0.0f;
- float max = 0.0f;
Q3DSPresentation *presentation = nullptr;
-
- float getMin() const;
- float getMax() const;
};
QT_END_NAMESPACE
diff --git a/src/runtime/api/q3dspresentation.cpp b/src/runtime/api/q3dspresentation.cpp
index 2d127e9..2a1d9eb 100644
--- a/src/runtime/api/q3dspresentation.cpp
+++ b/src/runtime/api/q3dspresentation.cpp
@@ -542,8 +542,6 @@ QVariantList Q3DSPresentation::getDataInputs()
// in order for setValue calls to be correctly routed.
auto privDi = Q3DSDataInputPrivate::get(it);
privDi->presentation = this;
- privDi->max = d->dataInputMax(it->name());
- privDi->min = d->dataInputMin(it->name());
QVariant var(QVariant::fromValue(it));
ret.append(var);
}
@@ -568,8 +566,6 @@ QVector<Q3DSDataInput *> Q3DSPresentation::getDataInputs(const QVariant &metadat
for (auto &it : diList) {
auto privDi = Q3DSDataInputPrivate::get(it);
privDi->presentation = this;
- privDi->max = d->dataInputMax(it->name());
- privDi->min = d->dataInputMin(it->name());
ret.append(it);
}
return ret;
@@ -810,9 +806,14 @@ void Q3DSPresentationPrivate::registerInlineQmlSubPresentations(const QVector<Q3
inlineQmlSubPresentations += list;
}
-void Q3DSPresentationPrivate::setDataInputMinMax(const QString &name, float min, float max)
+void Q3DSPresentationPrivate::setDataInputMin(const QString &name, float min)
{
- controller->pcEngine()->setDataInputMinMax(name, min, max);
+ controller->pcEngine()->setDataInputMin(name, min);
+}
+
+void Q3DSPresentationPrivate::setDataInputMax(const QString &name, float max)
+{
+ controller->pcEngine()->setDataInputMax(name, max);
}
void Q3DSPresentationPrivate::setDataInputMetaData(const QString &diName,
diff --git a/src/runtime/api/q3dspresentation_p.h b/src/runtime/api/q3dspresentation_p.h
index 55e41bc..2f0129d 100644
--- a/src/runtime/api/q3dspresentation_p.h
+++ b/src/runtime/api/q3dspresentation_p.h
@@ -125,7 +125,8 @@ public:
bool compareElementPath(const QString &a, const QString &b) const;
void registerInlineQmlSubPresentations(const QVector<Q3DSInlineQmlSubPresentation *> &list);
void setDataInputMetaData(const QString &diName, const QVariant &key, const QVariant &metaData);
- void setDataInputMinMax(const QString &name, float min, float max);
+ void setDataInputMin(const QString &name, float min);
+ void setDataInputMax(const QString &name, float max);
float dataInputMin(const QString &name) const;
float dataInputMax(const QString &name) const;
diff --git a/src/runtime/q3dsengine.cpp b/src/runtime/q3dsengine.cpp
index d98409c..b1a186b 100644
--- a/src/runtime/q3dsengine.cpp
+++ b/src/runtime/q3dsengine.cpp
@@ -1566,10 +1566,19 @@ void Q3DSEngine::setDataInputMetaData(const QString &diName,
presentation()->setDataInputEntries(&m_dataInputEntries);
}
-void Q3DSEngine::setDataInputMinMax(const QString &name, float min, float max)
+void Q3DSEngine::setDataInputMin(const QString &name, float min)
{
if (m_dataInputEntries[name].type == Q3DSDataInputEntry::TypeRangedNumber) {
m_dataInputEntries[name].minValue = min;
+ // Push the min-max changes to main datainput map so that they are used
+ // when Q3DSDataInput::setValue is handled
+ presentation()->setDataInputEntries(&m_dataInputEntries);
+ }
+}
+
+void Q3DSEngine::setDataInputMax(const QString &name, float max)
+{
+ if (m_dataInputEntries[name].type == Q3DSDataInputEntry::TypeRangedNumber) {
m_dataInputEntries[name].maxValue = max;
// Push the min-max changes to main datainput map so that they are used
// when Q3DSDataInput::setValue is handled
diff --git a/src/runtime/q3dsengine_p.h b/src/runtime/q3dsengine_p.h
index 94624ab..ab43209 100644
--- a/src/runtime/q3dsengine_p.h
+++ b/src/runtime/q3dsengine_p.h
@@ -167,7 +167,8 @@ public:
void resize(const QSize &size, qreal dpr = qreal(1.0), bool forceSynchronous = false);
void setDataInputValue(const QString &name, const QVariant &value);
- void setDataInputMinMax(const QString &name, float min, float max);
+ void setDataInputMin(const QString &name, float min);
+ void setDataInputMax(const QString &name, float max);
QVector<Q3DSDataInput *> dataInputs() const;
QVector<Q3DSDataInput *> dataInputs(const QVariant &metadataKey) const;
bool isValidDataInput(const Q3DSDataInput *di) const;