1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Temporarily(?) use weak_ptr to reduce ram usage increase during long

game sessions
This commit is contained in:
Ivan Savenko
2025-03-16 17:35:31 +00:00
parent ded12f2df9
commit 8a0fed7b3a
4 changed files with 27 additions and 18 deletions

View File

@@ -58,13 +58,14 @@ std::shared_ptr<CDefFile> RenderHandler::getAnimationFile(const AnimationPath &
auto it = animationFiles.find(actualPath);
if (it != animationFiles.end())
return it->second;
{
auto locked = it->second.lock();
if (locked)
return locked;
}
if (!CResourceHandler::get()->existsResource(actualPath))
{
animationFiles[actualPath] = nullptr;
return nullptr;
}
auto result = std::make_shared<CDefFile>(actualPath);
@@ -200,7 +201,11 @@ std::shared_ptr<ScalableImageShared> RenderHandler::loadImageImpl(const ImageLoc
{
auto it = imageFiles.find(locator);
if (it != imageFiles.end())
return it->second;
{
auto locked = it->second.lock();
if (locked)
return locked;
}
auto sdlImage = loadImageFromFileUncached(locator);
auto scaledImage = std::make_shared<ScalableImageShared>(locator, sdlImage);