Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 5 files). Show all
Unified · Split
| @@ -260,6 +260,20 @@ bool ScriptEngine::setScriptContents(const QString& scriptContents, const QStrin · 259 unmodified lines | |||
| 260 | return true; | 260 | return true; |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 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 | |||
| 263 | void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) { | 277 | void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) { |
| 264 | if (_isRunning) { | 278 | if (_isRunning) { |
| 265 | return; | 279 | return; |