mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4884 from daltomi/debug
Proposal: remove boolean flag, The pointer *atlas == item.second not change in map::erase().
This commit is contained in:
commit
d74d21a6f0
|
@ -103,20 +103,18 @@ std::string FontAtlasCache::generateFontName(const std::string& fontFileName, in
|
|||
|
||||
bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas)
|
||||
{
|
||||
if (atlas)
|
||||
if (nullptr != atlas)
|
||||
{
|
||||
for( auto &item: _atlasMap )
|
||||
{
|
||||
if ( item.second == atlas )
|
||||
{
|
||||
bool removeFromList = false;
|
||||
if(item.second->isSingleReference())
|
||||
removeFromList = true;
|
||||
if( atlas->isSingleReference() )
|
||||
{
|
||||
_atlasMap.erase(item.first);
|
||||
}
|
||||
|
||||
item.second->release();
|
||||
|
||||
if (removeFromList)
|
||||
_atlasMap.erase(item.first);
|
||||
atlas->release();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -126,4 +124,4 @@ bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas)
|
|||
return false;
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
NS_CC_END
|
||||
|
|
|
@ -319,7 +319,7 @@ bool AssetsManager::uncompress()
|
|||
return false;
|
||||
}
|
||||
|
||||
string fullPath = _storagePath + fileName;
|
||||
const string fullPath = _storagePath + fileName;
|
||||
|
||||
// Check if this entry is a directory or a file.
|
||||
const size_t filenameLength = strlen(fileName);
|
||||
|
@ -339,15 +339,15 @@ bool AssetsManager::uncompress()
|
|||
//There are not directory entry in some case.
|
||||
//So we need to test whether the file directory exists when uncompressing file entry
|
||||
//, if does not exist then create directory
|
||||
string fileNameStr(fileName);
|
||||
const string fileNameStr(fileName);
|
||||
|
||||
size_t startIndex=0;
|
||||
|
||||
size_t index=fileNameStr.find("/",startIndex);
|
||||
|
||||
while(index!=-1)
|
||||
while(index != std::string::npos)
|
||||
{
|
||||
string dir=_storagePath+fileNameStr.substr(0,index);
|
||||
const string dir=_storagePath+fileNameStr.substr(0,index);
|
||||
|
||||
FILE *out = fopen(dir.c_str(), "r");
|
||||
|
||||
|
@ -501,7 +501,7 @@ int assetsManagerProgressFunc(void *ptr, double totalToDownload, double nowDownl
|
|||
bool AssetsManager::downLoad()
|
||||
{
|
||||
// Create a file to save package.
|
||||
string outFileName = _storagePath + TEMP_PACKAGE_FILE_NAME;
|
||||
const string outFileName = _storagePath + TEMP_PACKAGE_FILE_NAME;
|
||||
FILE *fp = fopen(outFileName.c_str(), "wb");
|
||||
if (! fp)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue