Fix AssetBus connection policy to re-lock the mutex afterward since some destructors in the calling methods are still altering the context (#5575)

Also made the unlock conditional.

Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
monroegm-disable-blank-issue-2
amzn-mike 4 years ago committed by GitHub
parent 0cea59d669
commit 63713ca284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -556,16 +556,24 @@ namespace AZ
Asset<AssetData> assetData(AssetInternal::GetAssetData(actualId, AZ::Data::AssetLoadBehavior::Default));
if (assetData)
{
auto curStatus = assetData->GetStatus();
auto isReady = assetData->GetStatus() == AssetData::AssetStatus::Ready;
bool isError = assetData->IsError();
connectLock.unlock();
if (curStatus == AssetData::AssetStatus::Ready)
{
handler->OnAssetReady(assetData);
}
else if (isError)
if (isReady || isError)
{
handler->OnAssetError(assetData);
connectLock.unlock();
if (isReady)
{
handler->OnAssetReady(assetData);
}
else if (isError)
{
handler->OnAssetError(assetData);
}
// Lock the mutex again since some destructors will be modifying the context afterwards
connectLock.lock();
}
}
}

Loading…
Cancel
Save