From b60478ac90db43e6986c19af66977eed7b037e2c Mon Sep 17 00:00:00 2001 From: rh101 Date: Fri, 29 Oct 2021 00:05:52 +1100 Subject: [PATCH] Revert "Ensure font atlas is correctly released even if it does not exist in the atlas cache." This reverts commit 8b27fdb83245438512e53821b458273e5303497c. --- cocos/2d/CCLabel.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index fd3dca12cb..18b852788f 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -540,11 +540,7 @@ Label::~Label() Node::removeAllChildrenWithCleanup(true); CC_SAFE_RELEASE_NULL(_reusedLetter); _batchNodes.clear(); - if (!FontAtlasCache::releaseFontAtlas(_fontAtlas)) - { - _fontAtlas->release(); - } - _fontAtlas = nullptr; + FontAtlasCache::releaseFontAtlas(_fontAtlas); } _batchCommands.clear(); _eventDispatcher->removeEventListener(_purgeTextureListener); @@ -566,10 +562,7 @@ void Label::reset() _lettersInfo.clear(); if (_fontAtlas) { - if (!FontAtlasCache::releaseFontAtlas(_fontAtlas)) - { - _fontAtlas->release(); - } + FontAtlasCache::releaseFontAtlas(_fontAtlas); _fontAtlas = nullptr; } @@ -797,10 +790,7 @@ void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false * if (_fontAtlas) { _batchNodes.clear(); - if (!FontAtlasCache::releaseFontAtlas(_fontAtlas)) - { - _fontAtlas->release(); - } + FontAtlasCache::releaseFontAtlas(_fontAtlas); } _fontAtlas = atlas; @@ -1633,10 +1623,7 @@ void Label::updateContent() _batchNodes.clear(); _batchCommands.clear(); CC_SAFE_RELEASE_NULL(_reusedLetter); - if (!FontAtlasCache::releaseFontAtlas(_fontAtlas)) - { - _fontAtlas->release(); - } + FontAtlasCache::releaseFontAtlas(_fontAtlas); _fontAtlas = nullptr; }