History

separate getAsset fail/then handlers

humbletim committed 8 years ago

Commit 76cbc4e1 parent 16ca0ee1 file · +4 −3Browse files

Showing the changes to libraries/script-engine/src/AssetScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/AssetScriptingInterface.cpp+4−3
@@ -236,11 +236,12 @@ void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope, · 235 unmodified lines
236 Promise fetched = jsPromiseReady(makePromise("fetched"), scope, callback);236 Promise fetched = jsPromiseReady(makePromise("fetched"), scope, callback);
237 Promise mapped = makePromise("mapped");237 Promise mapped = makePromise("mapped");
238 238
239 mapped->ready([=](QString error, QVariantMap result) {239 mapped->fail(fetched);
240 mapped->then([=](QVariantMap result) {
240 QString hash = result.value("hash").toString();241 QString hash = result.value("hash").toString();
241 QString url = result.value("url").toString();242 QString url = result.value("url").toString();
242 if (!error.isEmpty() || !AssetUtils::isValidHash(hash)) {243 if (!AssetUtils::isValidHash(hash)) {
243 fetched->reject(error.isEmpty() ? "internal hash error: " + hash : error, result);244 fetched->reject("internal hash error: " + hash, result);
244 } else {245 } else {
245 Promise promise = loadAsset(hash, decompress, responseType);246 Promise promise = loadAsset(hash, decompress, responseType);
246 promise->mixin(result);247 promise->mixin(result);