diff --git a/cocos/2d/CCSpriteFrameCache.cpp b/cocos/2d/CCSpriteFrameCache.cpp index 9eac614a751d..4788da85e767 100644 --- a/cocos/2d/CCSpriteFrameCache.cpp +++ b/cocos/2d/CCSpriteFrameCache.cpp @@ -762,8 +762,12 @@ bool SpriteFrameCache::PlistFramesCache::eraseFrame(const std::string &frame) auto itFrame = _indexFrame2plist.find(frame); if (itFrame != _indexFrame2plist.end()) { - _indexPlist2Frames[itFrame->second].erase(frame); //update index plist->[frameNames] + auto plist = itFrame->second; + _indexPlist2Frames[plist].erase(frame); //update index plist->[frameNames] _indexFrame2plist.erase(itFrame); //update index frame->plist + // erase plist index if all frames was erased + if (_indexFrame2plist.empty()) + _indexPlist2Frames.erase(plist); return true; } return false; diff --git a/tests/cpp-tests/Resources/Images/island_polygon.png b/tests/cpp-tests/Resources/Images/island_polygon.png index 3302f98ef4e8..9f2a1b6987be 100644 Binary files a/tests/cpp-tests/Resources/Images/island_polygon.png and b/tests/cpp-tests/Resources/Images/island_polygon.png differ diff --git a/tests/cpp-tests/Resources/Images/sprite_frames_test/test_A8.png b/tests/cpp-tests/Resources/Images/sprite_frames_test/test_A8.png index 397d384839a4..2f4630804f40 100644 Binary files a/tests/cpp-tests/Resources/Images/sprite_frames_test/test_A8.png and b/tests/cpp-tests/Resources/Images/sprite_frames_test/test_A8.png differ diff --git a/tests/cpp-tests/Resources/Images/sprite_polygon_crash.png b/tests/cpp-tests/Resources/Images/sprite_polygon_crash.png index d421a0514790..781f91db8de6 100644 Binary files a/tests/cpp-tests/Resources/Images/sprite_polygon_crash.png and b/tests/cpp-tests/Resources/Images/sprite_polygon_crash.png differ