Function based endpoints should inhibit spamming with repeats of the same value

This commit is contained in:
Brad Davis 2015-10-24 16:26:29 -07:00
parent f61cf843bc
commit 5bc736952a
2 changed files with 8 additions and 3 deletions

View file

@ -14,7 +14,7 @@ using namespace controller;
float ScriptEndpoint::value() {
updateValue();
return _lastValue;
return _lastValueRead;
}
void ScriptEndpoint::updateValue() {
@ -23,14 +23,18 @@ void ScriptEndpoint::updateValue() {
return;
}
_lastValue = (float)_callable.call().toNumber();
_lastValueRead = (float)_callable.call().toNumber();
}
void ScriptEndpoint::apply(float newValue, float oldValue, const Pointer& source) {
if (newValue == _lastValueWritten) {
return;
}
internalApply(newValue, oldValue, source->getInput().getID());
}
void ScriptEndpoint::internalApply(float newValue, float oldValue, int sourceID) {
_lastValueWritten = newValue;
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "internalApply", Qt::QueuedConnection,
Q_ARG(float, newValue),

View file

@ -31,7 +31,8 @@ protected:
Q_INVOKABLE virtual void internalApply(float newValue, float oldValue, int sourceID);
private:
QScriptValue _callable;
float _lastValue = 0.0f;
float _lastValueRead { 0.0f };
float _lastValueWritten { 0.0f };
};
}