From 08dad985928b946cdcf39efadc0b7f1c1cb7fe3b Mon Sep 17 00:00:00 2001 From: "Daniel T. Borelli" Date: Sat, 4 Jan 2014 07:22:50 -0300 Subject: [PATCH 1/5] map:erase() is safe for item.second == FontAtlas* --- cocos/2d/CCFontAtlasCache.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cocos/2d/CCFontAtlasCache.cpp b/cocos/2d/CCFontAtlasCache.cpp index b72b76540c..69eebc083a 100644 --- a/cocos/2d/CCFontAtlasCache.cpp +++ b/cocos/2d/CCFontAtlasCache.cpp @@ -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 \ No newline at end of file +NS_CC_END From 8ffb05b6c9f4a057179710952f605c2206d80202 Mon Sep 17 00:00:00 2001 From: "Daniel T. Borelli" Date: Sat, 4 Jan 2014 19:26:16 -0300 Subject: [PATCH 2/5] Linux fix missing file -> rename dir loadSceneEditorFileTest to LoadScene...; add string::npos; const correctness --- extensions/assets-manager/AssetsManager.cpp | 10 +++++----- .../Images/startMenuBG.png.REMOVED.git-id | 0 .../Misc/music_logo.mp3.REMOVED.git-id | 0 .../Misc/music_logo.wav.REMOVED.git-id | 0 .../Butterflyfish/Butterflyfish0.png.REMOVED.git-id | 0 .../fishes/blowFish/Blowfish0.png.REMOVED.git-id | 0 .../Fish_UI/ui_logo_001-hd.png.REMOVED.git-id | 0 7 files changed, 5 insertions(+), 5 deletions(-) rename samples/Cpp/TestCpp/Resources/scenetest/{loadSceneEdtiorFileTest => LoadSceneEdtiorFileTest}/Images/startMenuBG.png.REMOVED.git-id (100%) rename samples/Cpp/TestCpp/Resources/scenetest/{loadSceneEdtiorFileTest => LoadSceneEdtiorFileTest}/Misc/music_logo.mp3.REMOVED.git-id (100%) rename samples/Cpp/TestCpp/Resources/scenetest/{loadSceneEdtiorFileTest => LoadSceneEdtiorFileTest}/Misc/music_logo.wav.REMOVED.git-id (100%) rename samples/Cpp/TestCpp/Resources/scenetest/{loadSceneEdtiorFileTest => LoadSceneEdtiorFileTest}/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id (100%) rename samples/Cpp/TestCpp/Resources/scenetest/{loadSceneEdtiorFileTest => LoadSceneEdtiorFileTest}/fishes/blowFish/Blowfish0.png.REMOVED.git-id (100%) rename samples/Cpp/TestCpp/Resources/scenetest/{loadSceneEdtiorFileTest => LoadSceneEdtiorFileTest}/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id (100%) diff --git a/extensions/assets-manager/AssetsManager.cpp b/extensions/assets-manager/AssetsManager.cpp index 52080d811c..23818d9e6d 100644 --- a/extensions/assets-manager/AssetsManager.cpp +++ b/extensions/assets-manager/AssetsManager.cpp @@ -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) { diff --git a/samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/Images/startMenuBG.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Images/startMenuBG.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/Images/startMenuBG.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Images/startMenuBG.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/Misc/music_logo.mp3.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.mp3.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/Misc/music_logo.mp3.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.mp3.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/Misc/music_logo.wav.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/Butterflyfish/Butterflyfish0.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/fishes/blowFish/Blowfish0.png.REMOVED.git-id diff --git a/samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id b/samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id similarity index 100% rename from samples/Cpp/TestCpp/Resources/scenetest/loadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id rename to samples/Cpp/TestCpp/Resources/scenetest/LoadSceneEdtiorFileTest/startMenu/Fish_UI/ui_logo_001-hd.png.REMOVED.git-id From 704d05521e63dd5d890a90214501d4e3900d5ab4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 6 Jan 2014 11:09:58 +0800 Subject: [PATCH 3/5] Update AUTHORS [ci skip] --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 37572f6171..7b76f10faa 100644 --- a/AUTHORS +++ b/AUTHORS @@ -702,6 +702,7 @@ Developers: daltomi Fixed a typo in Director class. + Removed an unnecessary boolean flag in CCFontAtlasCache.cpp. Retired Core Developers: WenSheng Yang From 7e279219ff376b8600bec3c8a99a83006a231e88 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Mon, 6 Jan 2014 11:12:44 +0800 Subject: [PATCH 4/5] Fix:Resolve the error that CocoStudioSceneTest load resource in android --- samples/Lua/TestLua/Classes/AppDelegate.cpp | 4 ++-- .../CocoStudioSceneTest/CocoStudioSceneTest.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/Lua/TestLua/Classes/AppDelegate.cpp b/samples/Lua/TestLua/Classes/AppDelegate.cpp index d07fb61f22..3979bbd41c 100644 --- a/samples/Lua/TestLua/Classes/AppDelegate.cpp +++ b/samples/Lua/TestLua/Classes/AppDelegate.cpp @@ -61,11 +61,11 @@ bool AppDelegate::applicationDidFinishLaunching() searchPaths.insert(searchPaths.begin(), "cocosbuilderRes"); if (screenSize.height > 320) { - searchPaths.insert(searchPaths.begin(), "hd/scenetest"); + searchPaths.insert(searchPaths.begin(), "hd/scenetest/loadSceneEdtiorFileTest"); } else { - searchPaths.insert(searchPaths.begin(), "scenetest"); + searchPaths.insert(searchPaths.begin(), "scenetest/loadSceneEdtiorFileTest"); } #if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua index 019809580c..e70ffd6262 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -16,7 +16,7 @@ function SceneEditorTestLayer.extend(target) end function SceneEditorTestLayer:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/FishJoy2.json") + local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/loadSceneEdtiorFileTest/FishJoy2.json") if nil == node then return end From d5d213aa0aff087f09adce2e295a2181ac2d1425 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Mon, 6 Jan 2014 11:19:40 +0800 Subject: [PATCH 5/5] Fix:Update the file spelling --- samples/Lua/TestLua/Classes/AppDelegate.cpp | 4 ++-- .../CocoStudioSceneTest/CocoStudioSceneTest.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/Lua/TestLua/Classes/AppDelegate.cpp b/samples/Lua/TestLua/Classes/AppDelegate.cpp index 3979bbd41c..98f5922eec 100644 --- a/samples/Lua/TestLua/Classes/AppDelegate.cpp +++ b/samples/Lua/TestLua/Classes/AppDelegate.cpp @@ -61,11 +61,11 @@ bool AppDelegate::applicationDidFinishLaunching() searchPaths.insert(searchPaths.begin(), "cocosbuilderRes"); if (screenSize.height > 320) { - searchPaths.insert(searchPaths.begin(), "hd/scenetest/loadSceneEdtiorFileTest"); + searchPaths.insert(searchPaths.begin(), "hd/scenetest/LoadSceneEdtiorFileTest"); } else { - searchPaths.insert(searchPaths.begin(), "scenetest/loadSceneEdtiorFileTest"); + searchPaths.insert(searchPaths.begin(), "scenetest/LoadSceneEdtiorFileTest"); } #if CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua index e70ffd6262..3c453756a4 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioSceneTest/CocoStudioSceneTest.lua @@ -16,7 +16,7 @@ function SceneEditorTestLayer.extend(target) end function SceneEditorTestLayer:createGameScene() - local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/loadSceneEdtiorFileTest/FishJoy2.json") + local node = ccs.SceneReader:getInstance():createNodeWithSceneFile("scenetest/LoadSceneEdtiorFileTest/FishJoy2.json") if nil == node then return end