From 196a924f892687be724ada514dc018048179aa1f Mon Sep 17 00:00:00 2001 From: Timur Losev Date: Sun, 22 Jun 2014 20:53:01 +0300 Subject: [PATCH] - Due to the fact that map::insert doesn't allow to insert an element by existing key, I suggest to use operator []. It allows to change the cached value, very helpful on Android platform: when context is lost, the application will reset - rebuild - recache all it's shaders. --- cocos/renderer/CCGLProgramCache.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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