[LYN-3464] Vegetation unit tests intermittently failed due to an AssetManager bug. Inside the AssetContainer, if the root asset finished loading during the container initialization, the CheckReady() call at the end of initialization would detect the loaded asset, but would skip sending out notifications because the initialized flag wasn't set yet. This would lead to an extra asset reference remaining in the AssetManager itself, would would then cause errors when the asset handler for that asset got removed.

By setting the initialization flag before the CheckReady() call, the notifications get sent correctly, and no extra asset references remain.  This checkin also includes a unit test for the AssetManager that specifically forces this condition to happen and validates that it works correctly.
This commit is contained in:
mbalfour
2021-05-04 09:04:18 -05:00
parent 781415755d
commit 5df82caef6
4 changed files with 176 additions and 5 deletions
@@ -239,8 +239,13 @@ namespace AZ
return;
}
CheckReady();
m_initComplete = true;
// *After* setting initComplete to true, check to see if the assets are already ready.
// This check needs to wait until after setting initComplete because if they *are* ready, we want the final call to
// RemoveWaitingAsset to trigger the OnAssetContainer* event. If we call CheckReady() *before* setting initComplete,
// if all the assets are ready, the event will never get triggered.
CheckReady();
}
bool AssetContainer::IsReady() const