Catch readTexture exceptions on CTextureCache::resolve so multi-background setups can properly lookup files...

This might need further improvements to use a texture cache by background instead of globally...

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2023-04-21 03:09:18 +02:00
parent a713ad001a
commit 0387ebc588

View File

@ -23,6 +23,8 @@ const ITexture* CTextureCache::resolve (const std::string& filename)
// search for the texture in all the different containers just in case
for (auto it : this->getContext ().getApp ().getBackgrounds ())
{
try
{
const ITexture* texture = it.second->getContainer ()->readTexture (filename);
@ -30,16 +32,27 @@ const ITexture* CTextureCache::resolve (const std::string& filename)
return texture;
}
catch (CAssetLoadException& ex)
{
// ignored, this happens if we're looking at the wrong background
}
}
if (this->getContext ().getApp ().getDefaultBackground () != nullptr)
{
const ITexture* texture =
this->getContext ().getApp ().getDefaultBackground ()->getContainer ()->readTexture (filename);
try
{
const ITexture* texture = this->getContext ().getApp ().getDefaultBackground ()->getContainer ()->readTexture (filename);
this->store (filename, texture);
return texture;
}
catch (CAssetLoadException& ex)
{
// ignored, this happens if we're looking at the wrong background
}
}
throw CAssetLoadException (filename, "Cannot find file");
}