Merge pull request #16117 from ctrlaltdavid/BUGZ-1316

BUGZ-1316: Fix crashes in Assets API
This commit is contained in:
Shannon Romano 2019-08-29 09:07:37 -07:00 committed by GitHub
commit b4d0c87654
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -127,6 +127,9 @@ void AssetScriptingInterface::setBakingEnabled(QString path, bool enabled, QScri
auto setBakingEnabledRequest = DependencyManager::get<AssetClient>()->createSetBakingEnabledRequest({ path }, enabled);
Promise deferred = jsPromiseReady(makePromise(__FUNCTION__), thisObject(), callback);
if (!deferred) {
return;
}
connect(setBakingEnabledRequest, &SetBakingEnabledRequest::finished, setBakingEnabledRequest, [deferred](SetBakingEnabledRequest* request) {
Q_ASSERT(QThread::currentThread() == request->thread());
@ -249,8 +252,11 @@ void AssetScriptingInterface::getAsset(QScriptValue options, QScriptValue scope,
QString("Invalid responseType: '%1' (expected: %2)").arg(responseType).arg(RESPONSE_TYPES.join(" | ")));
Promise fetched = jsPromiseReady(makePromise("fetched"), scope, callback);
Promise mapped = makePromise("mapped");
if (!fetched) {
return;
}
Promise mapped = makePromise("mapped");
mapped->fail(fetched);
mapped->then([=](QVariantMap result) {
QString hash = result.value("hash").toString();