Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 spriteframe erase fix #20580

Open
wants to merge 7 commits into
base: v4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions cocos/2d/CCSpriteFrameCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,18 +725,23 @@ void SpriteFrameCache::PlistFramesCache::insertFrame(const std::string &plist, c
bool SpriteFrameCache::PlistFramesCache::eraseFrame(const std::string &frame)
{
_spriteFrames.erase(frame); //drop SpriteFrame
auto itFrame = _indexFrame2plist.find(frame);
const auto itFrame = _indexFrame2plist.find(frame);
if (itFrame != _indexFrame2plist.end())
{
auto plist = itFrame->second;
const auto plist = itFrame->second;
markPlistFull(plist, false);
_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())

auto plist2FramesItr = _indexPlist2Frames.find(plist);
if (_indexPlist2Frames.end() != plist2FramesItr)
{
_indexPlist2Frames.erase(plist);
plist2FramesItr->second.erase(frame); //update index plist->[frameNames]
if (plist2FramesItr->second.empty())
{
// erase plist index if all frames was erased
_indexPlist2Frames.erase(plist2FramesItr);
}
}
_indexFrame2plist.erase(itFrame); //update index frame->plist
return true;
}
return false;
Expand All @@ -749,8 +754,7 @@ bool SpriteFrameCache::PlistFramesCache::eraseFrames(const std::vector<std::stri
{
ret |= eraseFrame(frame);
}
_indexPlist2Frames.clear();
_indexFrame2plist.clear();

return ret;
}

Expand Down