Add Ability to Pass Parameters When Calling Methods on Entities
Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 7 files). Show all
Unified · Split
| @@ -18,6 +18,7 @@ · 17 unmodified lines | ||
| 18 | 18 | #include <QtNetwork/QNetworkReply> |
| 19 | 19 | #include <QtScript/QScriptEngine> |
| 20 | 20 | #include <QtScript/QScriptValue> |
| 21 | +#include <QtCore/QStringList> | |
| 21 | 22 | |
| 22 | 23 | #include <AudioConstants.h> |
| 23 | 24 | #include <AudioEffectOptions.h> |
| @@ -1170,8 +1171,7 @@ void ScriptEngine::refreshFileScript(const EntityItemID& entityID) { · 1146 unmodified lines | ||
| 1170 | 1171 | recurseGuard = false; |
| 1171 | 1172 | } |
| 1172 | 1173 | |
| 1173 | − | |
| 1174 | −void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName) { | |
| 1174 | +void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName, const QStringList& params) { | |
| 1175 | 1175 | if (QThread::currentThread() != thread()) { |
| 1176 | 1176 | #ifdef THREAD_DEBUGGING |
| 1177 | 1177 | qDebug() << "*** WARNING *** ScriptEngine::callEntityScriptMethod() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] " |
| @@ -1180,7 +1180,8 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 2 unmodified lines | ||
| 1180 | 1180 | |
| 1181 | 1181 | QMetaObject::invokeMethod(this, "callEntityScriptMethod", |
| 1182 | 1182 | Q_ARG(const EntityItemID&, entityID), |
| 1183 | − Q_ARG(const QString&, methodName)); | |
| 1183 | + Q_ARG(const QString&, methodName), | |
| 1184 | + Q_ARG(const QStringList&, params)); | |
| 1184 | 1185 | return; |
| 1185 | 1186 | } |
| 1186 | 1187 | #ifdef THREAD_DEBUGGING |
| @@ -1195,6 +1196,7 @@ void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QS · 8 unmodified lines | ||
| 1195 | 1196 | if (entityScript.property(methodName).isFunction()) { |
| 1196 | 1197 | QScriptValueList args; |
| 1197 | 1198 | args << entityID.toScriptValue(this); |
| 1199 | + args << qScriptValueFromSequence(this, params); | |
| 1198 | 1200 | entityScript.property(methodName).call(entityScript, args); |
| 1199 | 1201 | } |
| 1200 | 1202 | |