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

@ -237,20 +237,19 @@ bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas)
{ {
if (nullptr != atlas) if (nullptr != atlas)
{ {
for( auto &item: _atlasMap ) if (atlas->getReferenceCount() == 1)
{ {
if ( item.second == atlas ) for( auto &item: _atlasMap )
{ {
if (atlas->getReferenceCount() == 1) if ( item.second == atlas )
{ {
_atlasMap.erase(item.first); _atlasMap.erase(item.first);
break;
} }
atlas->release();
return true;
} }
} }
atlas->release();
return true;
} }
return false; return false;