History

Fix crash in Assets.getAsset() when callback undefined

David Rowe committed 7 years ago

Commit 746f97a1 parent a9fe2bf1 file · +4 −1Browse 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−1
@@ -249,8 +249,11 @@ void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope, · 248 unmodified lines
249249 QString("Invalid responseType: '%1' (expected: %2)").arg(responseType).arg(RESPONSE_TYPES.join(" | ")));
250250
251251 Promise fetched = jsPromiseReady(makePromise("fetched"), scope, callback);
252− Promise mapped = makePromise("mapped");
252+ if (!fetched) {
253+ return;
254+ }
253255
256+ Promise mapped = makePromise("mapped");
254257 mapped->fail(fetched);
255258 mapped->then([=](QVariantMap result) {
256259 QString hash = result.value("hash").toString();