Skip to content

Commit a9dbbac

Browse files
drelaptophuangwei1024
authored andcommitted
fix cpp-tests SpritePolygon crash, wrong png format (cocos2d#19170)
* fix wrong png convert format from sRGB to Gray * erase plist index if all frames was erased * test_A8.png have I8 format, fix it
1 parent e262b9e commit a9dbbac

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

cocos/2d/CCSpriteFrameCache.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,12 @@ bool SpriteFrameCache::PlistFramesCache::eraseFrame(const std::string &frame)
762762
auto itFrame = _indexFrame2plist.find(frame);
763763
if (itFrame != _indexFrame2plist.end())
764764
{
765-
_indexPlist2Frames[itFrame->second].erase(frame); //update index plist->[frameNames]
765+
auto plist = itFrame->second;
766+
_indexPlist2Frames[plist].erase(frame); //update index plist->[frameNames]
766767
_indexFrame2plist.erase(itFrame); //update index frame->plist
768+
// erase plist index if all frames was erased
769+
if (_indexFrame2plist.empty())
770+
_indexPlist2Frames.erase(plist);
767771
return true;
768772
}
769773
return false;
Loading
Loading
Loading

0 commit comments

Comments
 (0)