Showing the changes to libraries/script-engine/src/AssetScriptingInterface.cpp (1 of 21 files). Show all
Unified · Split
| @@ -74,7 +74,7 @@ void AssetScriptingInterface::uploadData(QString data, const ScriptValue& callba · 73 unmodified lines | |||
| 74 | auto upload = DependencyManager::get<AssetClient>()->createUpload(dataByteArray); | 74 | auto upload = DependencyManager::get<AssetClient>()->createUpload(dataByteArray); |
| 75 | 75 | ||
| 76 | Promise deferred = makePromise(__FUNCTION__); | 76 | Promise deferred = makePromise(__FUNCTION__); |
| 77 | Q_ASSERT(engine); | 77 | Q_ASSERT(engine()); |
| 78 | auto scriptEngine = engine(); | 78 | auto scriptEngine = engine(); |
| 79 | deferred->ready([=](QString error, QVariantMap result) { | 79 | deferred->ready([=](QString error, QVariantMap result) { |
| 80 | auto url = result.value("url").toString(); | 80 | auto url = result.value("url").toString(); |
| @@ -98,7 +98,7 @@ void AssetScriptingInterface::setMapping(QString path, QString hash, const Scrip · 17 unmodified lines | |||
| 98 | auto handler = jsBindCallback(thisObject(), callback); | 98 | auto handler = jsBindCallback(thisObject(), callback); |
| 99 | auto setMappingRequest = assetClient()->createSetMappingRequest(path, hash); | 99 | auto setMappingRequest = assetClient()->createSetMappingRequest(path, hash); |
| 100 | Promise deferred = makePromise(__FUNCTION__); | 100 | Promise deferred = makePromise(__FUNCTION__); |
| 101 | Q_ASSERT(engine); | 101 | Q_ASSERT(engine()); |
| 102 | auto scriptEngine = engine(); | 102 | auto scriptEngine = engine(); |
| 103 | deferred->ready([=](QString error, QVariantMap result) { | 103 | deferred->ready([=](QString error, QVariantMap result) { |
| 104 | jsCallback(handler, scriptEngine->newValue(error), result); | 104 | jsCallback(handler, scriptEngine->newValue(error), result); |
| @@ -136,7 +136,7 @@ void AssetScriptingInterface::downloadData(QString urlString, const ScriptValue& · 31 unmodified lines | |||
| 136 | auto assetRequest = assetClient->createRequest(hash); | 136 | auto assetRequest = assetClient->createRequest(hash); |
| 137 | 137 | ||
| 138 | Promise deferred = makePromise(__FUNCTION__); | 138 | Promise deferred = makePromise(__FUNCTION__); |
| 139 | Q_ASSERT(engine); | 139 | Q_ASSERT(engine()); |
| 140 | auto scriptEngine = engine(); | 140 | auto scriptEngine = engine(); |
| 141 | deferred->ready([=](QString error, QVariantMap result) { | 141 | deferred->ready([=](QString error, QVariantMap result) { |
| 142 | // FIXME: to remain backwards-compatible the signature here is "callback(data, n/a)" | 142 | // FIXME: to remain backwards-compatible the signature here is "callback(data, n/a)" |
| @@ -200,7 +200,7 @@ void AssetScriptingInterface::getMapping(QString asset, const ScriptValue& callb · 57 unmodified lines | |||
| 200 | JS_VERIFY(AssetUtils::isValidFilePath(path), "invalid ATP file path: " + asset + "(path:"+path+")"); | 200 | JS_VERIFY(AssetUtils::isValidFilePath(path), "invalid ATP file path: " + asset + "(path:"+path+")"); |
| 201 | JS_VERIFY(callback.isFunction(), "expected second parameter to be a callback function"); | 201 | JS_VERIFY(callback.isFunction(), "expected second parameter to be a callback function"); |
| 202 | Promise promise = getAssetInfo(path); | 202 | Promise promise = getAssetInfo(path); |
| 203 | Q_ASSERT(engine); | 203 | Q_ASSERT(engine()); |
| 204 | auto scriptEngine = engine(); | 204 | auto scriptEngine = engine(); |
| 205 | promise->ready([=](QString error, QVariantMap result) { | 205 | promise->ready([=](QString error, QVariantMap result) { |
| 206 | jsCallback(handler, scriptEngine->newValue(error), scriptEngine->newValue(result.value("hash").toString())); | 206 | jsCallback(handler, scriptEngine->newValue(error), scriptEngine->newValue(result.value("hash").toString())); |
| @@ -234,7 +234,7 @@ Promise AssetScriptingInterface::jsPromiseReady(Promise promise, const ScriptVal · 27 unmodified lines | |||
| 234 | if (!jsVerify(handler.isValid(), "jsPromiseReady -- invalid callback handler")) { | 234 | if (!jsVerify(handler.isValid(), "jsPromiseReady -- invalid callback handler")) { |
| 235 | return nullptr; | 235 | return nullptr; |
| 236 | } | 236 | } |
| 237 | Q_ASSERT(engine); | 237 | Q_ASSERT(engine()); |
| 238 | auto scriptEngine = engine(); | 238 | auto scriptEngine = engine(); |
| 239 | return promise->ready([this, handler, scriptEngine](QString error, QVariantMap result) { | 239 | return promise->ready([this, handler, scriptEngine](QString error, QVariantMap result) { |
| 240 | jsCallback(handler, scriptEngine->newValue(error), result); | 240 | jsCallback(handler, scriptEngine->newValue(error), result); |
| @@ -244,7 +244,7 @@ Promise AssetScriptingInterface::jsPromiseReady(Promise promise, const ScriptVal · 3 unmodified lines | |||
| 244 | void AssetScriptingInterface::jsCallback(const ScriptValue& handler, | 244 | void AssetScriptingInterface::jsCallback(const ScriptValue& handler, |
| 245 | const ScriptValue& error, const ScriptValue& result) { | 245 | const ScriptValue& error, const ScriptValue& result) { |
| 246 | Q_ASSERT(thread() == QThread::currentThread()); | 246 | Q_ASSERT(thread() == QThread::currentThread()); |
| 247 | Q_ASSERT(engine); | 247 | Q_ASSERT(engine()); |
| 248 | //V8TODO: which kind of script context guard needs to be used here? | 248 | //V8TODO: which kind of script context guard needs to be used here? |
| 249 | ScriptContextGuard scriptContextGuard(_scriptManager->engine()->currentContext()); | 249 | ScriptContextGuard scriptContextGuard(_scriptManager->engine()->currentContext()); |
| 250 | auto errorValue = !error.toBool() ? engine()->nullValue() : error; | 250 | auto errorValue = !error.toBool() ? engine()->nullValue() : error; |
| @@ -546,7 +546,7 @@ void AssetScriptingInterface::loadFromCache(const ScriptValue& options, const Sc · 295 unmodified lines | |||
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | bool AssetScriptingInterface::canWriteCacheValue(const QUrl& url) { | 548 | bool AssetScriptingInterface::canWriteCacheValue(const QUrl& url) { |
| 549 | Q_ASSERT(engine); | 549 | Q_ASSERT(engine()); |
| 550 | auto scriptManager = engine()->manager(); | 550 | auto scriptManager = engine()->manager(); |
| 551 | if (!scriptManager) { | 551 | if (!scriptManager) { |
| 552 | return false; | 552 | return false; |