The releaseFontAtlas method will remove the font atlas from the cache if it has a reference count of 1, and will always call release on that atlas as expected by the calling code.

This commit is contained in:
rh101 2021-10-29 00:07:46 +11:00
parent b60478ac90
commit 9b2b3de565
1 changed files with 8 additions and 9 deletions

View File

@ -236,22 +236,21 @@ FontAtlas* FontAtlasCache::getFontAtlasCharMap(const std::string& charMapFile, i
bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas)
{
if (nullptr != atlas)
{
if (atlas->getReferenceCount() == 1)
{
for( auto &item: _atlasMap )
{
if ( item.second == atlas )
{
if (atlas->getReferenceCount() == 1)
{
_atlasMap.erase(item.first);
break;
}
}
}
atlas->release();
return true;
}
}
}
return false;
}