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
236236 Promise fetched = jsPromiseReady(makePromise("fetched"), scope, callback);
237237 Promise mapped = makePromise("mapped");
238238
239− mapped->ready([=](QString error, QVariantMap result) {
239+ mapped->fail(fetched);
240+ mapped->then([=](QVariantMap result) {
240241 QString hash = result.value("hash").toString();
241242 QString url = result.value("url").toString();
242− if (!error.isEmpty() || !AssetUtils::isValidHash(hash)) {
243− fetched->reject(error.isEmpty() ? "internal hash error: " + hash : error, result);
243+ if (!AssetUtils::isValidHash(hash)) {
244+ fetched->reject("internal hash error: " + hash, result);
244245 } else {
245246 Promise promise = loadAsset(hash, decompress, responseType);
246247 promise->mixin(result);