Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Sep 17, 2020
1 parent fd5bb25 commit 22a4586
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cocos/2d/CCSpriteFrameCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,18 +728,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 @@ -752,9 +757,6 @@ bool SpriteFrameCache::PlistFramesCache::eraseFrames(const std::vector<std::stri
{
ret |= eraseFrame(frame);
}
_indexPlist2Frames.clear();
_indexFrame2plist.clear();
_isPlistFull.clear();
return ret;
}

Expand Down

0 comments on commit 22a4586

Please sign in to comment.