From 8578b40236d9f4dfbd9b4feb0098133ce94a2ece Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Sat, 17 Oct 2015 14:14:45 -0700 Subject: [PATCH] get JS source functions working across threads --- examples/example/scripts/controllerScriptingExamples.js | 3 +++ libraries/controllers/src/controllers/ScriptingInterface.cpp | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/example/scripts/controllerScriptingExamples.js b/examples/example/scripts/controllerScriptingExamples.js index 93e91c6b00..edf4dca414 100644 --- a/examples/example/scripts/controllerScriptingExamples.js +++ b/examples/example/scripts/controllerScriptingExamples.js @@ -29,6 +29,9 @@ if (hydra !== undefined) { var mapping = Controller.newMapping("Test"); var standard = Controller.Standard; print("standard:" + standard); + mapping.from(function () { return Math.sin(Date.now() / 250); }).to(function (newValue, oldValue, source) { + print("function source newValue:" + newValue + ", oldValue:" + oldValue + ", source:" + source); + }); mapping.from(hydra.L1).to(standard.A); mapping.from(hydra.L2).to(standard.B); mapping.from(hydra.L3).to(function (newValue, oldValue, source) { diff --git a/libraries/controllers/src/controllers/ScriptingInterface.cpp b/libraries/controllers/src/controllers/ScriptingInterface.cpp index 68095505af..9f9ca85dd4 100644 --- a/libraries/controllers/src/controllers/ScriptingInterface.cpp +++ b/libraries/controllers/src/controllers/ScriptingInterface.cpp @@ -62,9 +62,7 @@ namespace controller { }; float ScriptEndpoint::value() { - if (QThread::currentThread() == thread()) { - updateValue(); - } + updateValue(); return _lastValue; }