History

first cut at making sure entity scripts are called on the entities script engine thread

Brad Hefta-Gaub committed 11 years ago

Commit 8eacdbf1 parent e8ede3a5 files · +62 −21Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 5 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+14−0
@@ -260,6 +260,20 @@ bool ScriptEngine::setScriptContents(const QString& scriptContents, const QStrin · 259 unmodified lines
260260 return true;
261261 }
262262
263+void ScriptEngine::callScriptMethod(QString methodName, QScriptValue script, QScriptValueList args) {
264+ if (QThread::currentThread() != thread()) {
265+ QMetaObject::invokeMethod(this,
266+ "callScriptMethod",
267+ Q_ARG(QString, methodName),
268+ Q_ARG(QScriptValue, script),
269+ Q_ARG(QScriptValueList, args));
270+ return;
271+ }
272+
273+ qDebug() << "About to call " << methodName << "() current thread : " << QThread::currentThread() << "engine thread : " << thread();
274+ script.property(methodName).call(script, args);
275+}
276+
263277 void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
264278 if (_isRunning) {
265279 return;