From 777ec2662ef5ee8b0a501e0b8a9b2d7a2b84ffe7 Mon Sep 17 00:00:00 2001 From: Jason Sams Date: Thu, 18 Aug 2011 18:01:33 -0700 Subject: Fix issue with freeing allocation with circular references. Change-Id: I45871c20a192815eafee77f95e17a025f6dcf9d1 --- libs/rs/rsProgram.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'libs/rs/rsProgram.cpp') diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp index 33eb422..4178aa5 100644 --- a/libs/rs/rsProgram.cpp +++ b/libs/rs/rsProgram.cpp @@ -70,15 +70,8 @@ Program::Program(Context *rsc, const char * shaderText, uint32_t shaderLength, } Program::~Program() { + freeChildren(); - for (uint32_t ct=0; ct < mHal.state.constantsCount; ct++) { - bindAllocation(NULL, NULL, ct); - } - - for (uint32_t ct=0; ct < mHal.state.texturesCount; ct++) { - bindTexture(NULL, ct, NULL); - bindSampler(NULL, ct, NULL); - } delete[] mHal.state.textures; delete[] mHal.state.samplers; delete[] mHal.state.textureTargets; @@ -90,6 +83,18 @@ Program::~Program() { mHal.state.texturesCount = 0; } +bool Program::freeChildren() { + for (uint32_t ct=0; ct < mHal.state.constantsCount; ct++) { + bindAllocation(NULL, NULL, ct); + } + + for (uint32_t ct=0; ct < mHal.state.texturesCount; ct++) { + bindTexture(NULL, ct, NULL); + bindSampler(NULL, ct, NULL); + } + return false; +} + void Program::initMemberVars() { mDirty = true; -- cgit v1.1