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

Also made the unlock conditional.

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

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

Loading…
Cancel
Save