mirror of https://github.com/axmolengine/axmol.git
Merge pull request #8921 from TimothyZhang/fix-program-cache-add
release old program with the same key before adding glprogram
This commit is contained in:
commit
f1ac0df761
|
@ -432,9 +432,16 @@ GLProgram* GLProgramCache::getGLProgram(const std::string &key)
|
|||
|
||||
void GLProgramCache::addGLProgram(GLProgram* program, const std::string &key)
|
||||
{
|
||||
// release old one
|
||||
auto prev = getProgram(key);
|
||||
if( prev == program )
|
||||
return;
|
||||
|
||||
_programs.erase(key);
|
||||
CC_SAFE_RELEASE_NULL(prev);
|
||||
|
||||
if (program)
|
||||
program->retain();
|
||||
|
||||
_programs[key] = program;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue