Showing the changes to libraries/script-engine/src/qtscript/ScriptEngineQtScript.cpp (1 of 11 files). Show all
Unified · Split
| @@ -52,15 +52,9 @@ · 51 unmodified lines | |||
| 52 | #include "ScriptObjectQtProxy.h" | 52 | #include "ScriptObjectQtProxy.h" |
| 53 | #include "ScriptProgramQtWrapper.h" | 53 | #include "ScriptProgramQtWrapper.h" |
| 54 | #include "ScriptValueQtWrapper.h" | 54 | #include "ScriptValueQtWrapper.h" |
| 55 | #include "ScriptContextQtAgent.h" | ||
| 56 | 55 | ||
| 57 | static const int MAX_DEBUG_VALUE_LENGTH { 80 }; | 56 | static const int MAX_DEBUG_VALUE_LENGTH { 80 }; |
| 58 | 57 | ||
| 59 | Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature) | ||
| 60 | int qfunctionSignatureMetaID = qRegisterMetaType<QScriptEngine::FunctionSignature>(); | ||
| 61 | |||
| 62 | int scriptEnginePointerMetaID = qRegisterMetaType<ScriptEngineQtScriptPointer>(); | ||
| 63 | |||
| 64 | bool ScriptEngineQtScript::IS_THREADSAFE_INVOCATION(const QThread* thread, const QString& method) { | 58 | bool ScriptEngineQtScript::IS_THREADSAFE_INVOCATION(const QThread* thread, const QString& method) { |
| 65 | const QThread* currentThread = QThread::currentThread(); | 59 | const QThread* currentThread = QThread::currentThread(); |
| 66 | if (currentThread == thread) { | 60 | if (currentThread == thread) { |
| @@ -336,13 +330,6 @@ ScriptEngineQtScript::ScriptEngineQtScript(ScriptManager* scriptManager) : · 269 unmodified lines | |||
| 336 | _undefinedValue = ScriptValue(new ScriptValueQtWrapper(this, std::move(undefined))); | 330 | _undefinedValue = ScriptValue(new ScriptValueQtWrapper(this, std::move(undefined))); |
| 337 | 331 | ||
| 338 | QScriptEngine::setProcessEventsInterval(MSECS_PER_SECOND); | 332 | QScriptEngine::setProcessEventsInterval(MSECS_PER_SECOND); |
| 339 | |||
| 340 | _contextAgent = new ScriptContextQtAgent(this, agent()); | ||
| 341 | setAgent(_contextAgent); | ||
| 342 | } | ||
| 343 | |||
| 344 | ScriptEngineQtScript::~ScriptEngineQtScript() { | ||
| 345 | delete _contextAgent; | ||
| 346 | } | 333 | } |
| 347 | 334 | ||
| 348 | void ScriptEngineQtScript::registerEnum(const QString& enumName, QMetaEnum newEnum) { | 335 | void ScriptEngineQtScript::registerEnum(const QString& enumName, QMetaEnum newEnum) { |
| @@ -912,20 +899,20 @@ ScriptValue ScriptEngineQtScript::create(int type, const void* ptr) { · 563 unmodified lines | |||
| 912 | return ScriptValue(new ScriptValueQtWrapper(this, std::move(scriptValue))); | 899 | return ScriptValue(new ScriptValueQtWrapper(this, std::move(scriptValue))); |
| 913 | } | 900 | } |
| 914 | 901 | ||
| 915 | QVariant ScriptEngineQtScript::convert(const ScriptValue& value, int type) { | 902 | QVariant ScriptEngineQtScript::convert(const ScriptValue& value, int typeId) { |
| 916 | ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(value); | 903 | ScriptValueQtWrapper* unwrapped = ScriptValueQtWrapper::unwrap(value); |
| 917 | if (unwrapped == nullptr) { | 904 | if (unwrapped == nullptr) { |
| 918 | return QVariant(); | 905 | return QVariant(); |
| 919 | } | 906 | } |
| 920 | 907 | ||
| 921 | QVariant var; | 908 | QVariant var; |
| 922 | if (!castValueToVariant(unwrapped->toQtValue(), var, type)) { | 909 | if (!castValueToVariant(unwrapped->toQtValue(), var, typeId)) { |
| 923 | return QVariant(); | 910 | return QVariant(); |
| 924 | } | 911 | } |
| 925 | 912 | ||
| 926 | int destType = var.userType(); | 913 | int destType = var.userType(); |
| 927 | if (destType != type) { | 914 | if (destType != typeId) { |
| 928 | var.convert(type); // if conversion fails then var is set to QVariant() | 915 | var.convert(typeId); // if conversion fails then var is set to QVariant() |
| 929 | } | 916 | } |
| 930 | 917 | ||
| 931 | return var; | 918 | return var; |