From 0387ebc588027e8f279201e943a0ec68b093ca32 Mon Sep 17 00:00:00 2001 From: Alexis Maiquez Date: Fri, 21 Apr 2023 03:09:18 +0200 Subject: [PATCH] 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 --- src/WallpaperEngine/Render/CTextureCache.cpp | 27 +++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/WallpaperEngine/Render/CTextureCache.cpp b/src/WallpaperEngine/Render/CTextureCache.cpp index d4d3007..08bab28 100644 --- a/src/WallpaperEngine/Render/CTextureCache.cpp +++ b/src/WallpaperEngine/Render/CTextureCache.cpp @@ -24,21 +24,34 @@ 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 ()) { - const ITexture* texture = it.second->getContainer ()->readTexture (filename); + try + { + const ITexture* texture = it.second->getContainer ()->readTexture (filename); - this->store (filename, texture); + this->store (filename, texture); - return texture; + 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); + this->store (filename, texture); - return texture; + return texture; + } + catch (CAssetLoadException& ex) + { + // ignored, this happens if we're looking at the wrong background + } } throw CAssetLoadException (filename, "Cannot find file");