{"action":"created","issue":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15822","repository_url":"https://api.github.com/repos/cocos2d/cocos2d-x","labels_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15822/labels{/name}","comments_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15822/comments","events_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15822/events","html_url":"https://github.com/cocos2d/cocos2d-x/pull/15822","id":159789181,"number":15822,"title":"Fix assertion failure when running Sprite Test","user":{"login":"mogemimi","id":4461792,"avatar_url":"https://avatars.githubusercontent.com/u/4461792?v=3","gravatar_id":"","url":"https://api.github.com/users/mogemimi","html_url":"https://github.com/mogemimi","followers_url":"https://api.github.com/users/mogemimi/followers","following_url":"https://api.github.com/users/mogemimi/following{/other_user}","gists_url":"https://api.github.com/users/mogemimi/gists{/gist_id}","starred_url":"https://api.github.com/users/mogemimi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mogemimi/subscriptions","organizations_url":"https://api.github.com/users/mogemimi/orgs","repos_url":"https://api.github.com/users/mogemimi/repos","events_url":"https://api.github.com/users/mogemimi/events{/privacy}","received_events_url":"https://api.github.com/users/mogemimi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-11T19:11:24Z","updated_at":"2016-06-12T02:29:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/pulls/15822","html_url":"https://github.com/cocos2d/cocos2d-x/pull/15822","diff_url":"https://github.com/cocos2d/cocos2d-x/pull/15822.diff","patch_url":"https://github.com/cocos2d/cocos2d-x/pull/15822.patch"},"body":"When running `SpriteTests` in `cpp-tests`, I always get an error at the following assert.\r\n\r\n```\r\nSprite* Sprite::createWithSpriteFrameName(const std::string& spriteFrameName)\r\n{\r\n    SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(spriteFrameName);\r\n    \r\n#if COCOS2D_DEBUG > 0\r\n    char msg[256] = {0};\r\n    sprintf(msg, \"Invalid spriteFrameName: %s\", spriteFrameName.c_str());\r\n    CCASSERT(frame != nullptr, msg);\r\n#endif\r\n```\r\n\r\n**Version:**\r\n\r\n- Cocos2d-x v3.11.1 (latest version)\r\n\r\n**Steps to Reproduce:**\r\n\r\n1) Build and run `cpp-tests` in debug mode\r\n2) Open 'Node: Sprite' > '64:AnimationCache - Load file' (`AnimationCacheTest`)\r\n```cpp\r\n// at case 64, `AnimationCacheTest::AnimationCacheTest()`\r\nauto frameCache = SpriteFrameCache::getInstance();\r\nframeCache->addSpriteFramesWithFile(\"animations/grossini.plist\");\r\n```\r\n3) Switch to the test case '5:Testing SpriteFrame' (`SpriteAnchorPointFromFile`)\r\n```cpp\r\n// at case 5, `SpriteAnchorPointFromFile::onExit()`\r\nframeCache->removeSpriteFramesFromFile(\"animations/grossini_anchors.plist\");\r\n```\r\n4) Run the next case '6:Testing Sprite' (`SpriteOffsetAnchorRotation`), then crash\r\n```cpp\r\n// at case 6, `SpriteOffsetAnchorRotation::onEnter()`\r\nframeCache->addSpriteFramesWithFile(\"animations/grossini.plist\");\r\n\r\n// assert failed\r\nauto sprite = Sprite::createWithSpriteFrameName(\"grossini_dance_01.png\");\r\n```\r\n\r\n**Result:**\r\n\r\n```\r\nAssert failed: Invalid spriteFrameName: grossini_dance_01.png\r\nAssertion failed: (frame != nullptr), function createWithSpriteFrameName, file cocos/2d/CCSprite.cpp, line 127.\r\n```\r\n\r\nThis PR adds missing `SpriteFrameCache::removeSpriteFrameCache()` calls to fix assert failure.\r\nThank you for considering this. :)"},"comment":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/comments/225405953","html_url":"https://github.com/cocos2d/cocos2d-x/pull/15822#issuecomment-225405953","issue_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/15822","id":225405953,"user":{"login":"minggo","id":488203,"avatar_url":"https://avatars.githubusercontent.com/u/488203?v=3","gravatar_id":"","url":"https://api.github.com/users/minggo","html_url":"https://github.com/minggo","followers_url":"https://api.github.com/users/minggo/followers","following_url":"https://api.github.com/users/minggo/following{/other_user}","gists_url":"https://api.github.com/users/minggo/gists{/gist_id}","starred_url":"https://api.github.com/users/minggo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minggo/subscriptions","organizations_url":"https://api.github.com/users/minggo/orgs","repos_url":"https://api.github.com/users/minggo/repos","events_url":"https://api.github.com/users/minggo/events{/privacy}","received_events_url":"https://api.github.com/users/minggo/received_events","type":"User","site_admin":false},"created_at":"2016-06-12T02:29:00Z","updated_at":"2016-06-12T02:29:00Z","body":"Thanks."}}
{"actor":{"display_login":"minggo"}}