diff --git a/cocos/renderer/CCGLProgramCache.cpp b/cocos/renderer/CCGLProgramCache.cpp index 8c3f304eea..b451d2d7de 100644 --- a/cocos/renderer/CCGLProgramCache.cpp +++ b/cocos/renderer/CCGLProgramCache.cpp @@ -387,8 +387,10 @@ GLProgram* GLProgramCache::getGLProgram(const std::string &key) void GLProgramCache::addGLProgram(GLProgram* program, const std::string &key) { - program->retain(); - _programs.insert( std::make_pair( key, program) ); + if (program) + program->retain(); + + _programs[key] = program; } NS_CC_END