Commit 6a6f0f12 authored by Joachim Pouderoux's avatar Joachim Pouderoux
Browse files

Fix a memory leak that occures when Uniform Variables are updated

The Merge method called when some uniforms are added or changed
on a shader used to leak at each call. Fix that.

Change-Id: I46879903c2891cdf1dd94247d089621464a6f8db
parent aec1c0b7
......@@ -1107,26 +1107,25 @@ void vtkUniformVariables::Next()
// \pre not_self: other!=this
void vtkUniformVariables::Merge(vtkUniformVariables *other)
{
assert("pre: other_exists" && other!=0);
assert("pre: not_self" && other!=this);
assert("pre: other_exists" && other != 0);
assert("pre: not_self" && other != this);
other->Start();
while(!other->IsAtEnd())
while (!other->IsAtEnd())
{
const char *name=other->GetCurrentName();
UniformMapIt cur=other->Map->Map.find(name);
vtkUniform *u1=(*cur).second;
const char *name = other->GetCurrentName();
UniformMapIt prev = this->Map->Map.find(name);
if (prev != this->Map->Map.end())
{
delete prev->second;
this->Map->Map.erase(prev);
}
vtkUniform* clone = other->Map->It->second->Clone();
this->Map->Map[clone->GetName()] = clone;
vtkUniform *u2=u1->Clone();
vtksys_stl::pair<const char *, vtkUniform *> p;
p.first=u2->GetName();
p.second=u2;
this->Map->Map.erase(p.first);
this->Map->Map.insert(p);
other->Next();
}
if(other->Map->Map.size()>0)
if (other->Map->Map.size() > 0)
{
this->Modified();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment