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:
James Chen 2014-01-05 19:08:37 -08:00
commit d74d21a6f0
8 changed files with 12 additions and 14 deletions

View File

@ -103,20 +103,18 @@ std::string FontAtlasCache::generateFontName(const std::string& fontFileName, in
bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas) bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas)
{ {
if (atlas) if (nullptr != atlas)
{ {
for( auto &item: _atlasMap ) for( auto &item: _atlasMap )
{ {
if ( item.second == atlas ) if ( item.second == atlas )
{ {
bool removeFromList = false; if( atlas->isSingleReference() )
if(item.second->isSingleReference()) {
removeFromList = true; _atlasMap.erase(item.first);
}
item.second->release(); atlas->release();
if (removeFromList)
_atlasMap.erase(item.first);
return true; return true;
} }
@ -126,4 +124,4 @@ bool FontAtlasCache::releaseFontAtlas(FontAtlas *atlas)
return false; return false;
} }
NS_CC_END NS_CC_END

View File

@ -319,7 +319,7 @@ bool AssetsManager::uncompress()
return false; return false;
} }
string fullPath = _storagePath + fileName; const string fullPath = _storagePath + fileName;
// Check if this entry is a directory or a file. // Check if this entry is a directory or a file.
const size_t filenameLength = strlen(fileName); const size_t filenameLength = strlen(fileName);
@ -339,15 +339,15 @@ bool AssetsManager::uncompress()
//There are not directory entry in some case. //There are not directory entry in some case.
//So we need to test whether the file directory exists when uncompressing file entry //So we need to test whether the file directory exists when uncompressing file entry
//, if does not exist then create directory //, if does not exist then create directory
string fileNameStr(fileName); const string fileNameStr(fileName);
size_t startIndex=0; size_t startIndex=0;
size_t index=fileNameStr.find("/",startIndex); 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"); FILE *out = fopen(dir.c_str(), "r");
@ -501,7 +501,7 @@ int assetsManagerProgressFunc(void *ptr, double totalToDownload, double nowDownl
bool AssetsManager::downLoad() bool AssetsManager::downLoad()
{ {
// Create a file to save package. // 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"); FILE *fp = fopen(outFileName.c_str(), "wb");
if (! fp) if (! fp)
{ {