Skip to content

Commit

Permalink
Fix memory leaks in GenericCAO, ShaderSource and Player classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sapier authored and sapier committed Jul 2, 2014
1 parent 3d6d66b commit b8343cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/content_cao.cpp
Expand Up @@ -670,6 +670,7 @@ GenericCAO::~GenericCAO()
{
m_env->removePlayerName(m_name.c_str());
}
removeFromScene(true);
}

core::aabbox3d<f32>* GenericCAO::getSelectionBox()
Expand Down Expand Up @@ -735,7 +736,7 @@ ClientActiveObject* GenericCAO::getParent()

void GenericCAO::removeFromScene(bool permanent)
{
if(permanent) // Should be true when removing the object permanently and false when refreshing (eg: updating visuals)
if((m_env != 0) && (permanent)) // Should be true when removing the object permanently and false when refreshing (eg: updating visuals)
{
for(std::vector<u16>::iterator ci = m_children.begin();
ci != m_children.end(); ci++)
Expand Down
1 change: 1 addition & 0 deletions src/player.cpp
Expand Up @@ -100,6 +100,7 @@ Player::Player(IGameDef *gamedef):

Player::~Player()
{
clearHud();
}

// Horizontal acceleration (X and Z), Y direction is ignored
Expand Down
7 changes: 5 additions & 2 deletions src/shader.cpp
Expand Up @@ -383,13 +383,16 @@ ShaderSource::ShaderSource(IrrlichtDevice *device):

ShaderSource::~ShaderSource()
{
//m_shader_callback->drop();

for (std::vector<IShaderConstantSetter*>::iterator iter = m_global_setters.begin();
iter != m_global_setters.end(); iter++) {
delete *iter;
}
m_global_setters.clear();

if (m_shader_callback) {
m_shader_callback->drop();
m_shader_callback = NULL;
}
}

u32 ShaderSource::getShader(const std::string &name,
Expand Down

0 comments on commit b8343cd

Please sign in to comment.