aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-07-02 23:33:18 +0200
committersapier <Sapier at GMX dot net>2014-07-02 23:33:18 +0200
commitb8343cd11c834fb2613b104418ed08e9fdb1665a (patch)
tree27194eb00fb695367fcd5cb0e281639bf75a48b1 /src
parent3d6d66b181b894180164aa34aab7b2029bef1bf4 (diff)
downloadminetest-b8343cd11c834fb2613b104418ed08e9fdb1665a.tar.gz
minetest-b8343cd11c834fb2613b104418ed08e9fdb1665a.tar.bz2
minetest-b8343cd11c834fb2613b104418ed08e9fdb1665a.zip
Fix memory leaks in GenericCAO, ShaderSource and Player classes
Diffstat (limited to 'src')
-rw-r--r--src/content_cao.cpp3
-rw-r--r--src/player.cpp1
-rw-r--r--src/shader.cpp7
3 files changed, 8 insertions, 3 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index a05936d2c..fe11d33da 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -670,6 +670,7 @@ GenericCAO::~GenericCAO()
{
m_env->removePlayerName(m_name.c_str());
}
+ removeFromScene(true);
}
core::aabbox3d<f32>* GenericCAO::getSelectionBox()
@@ -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++)
diff --git a/src/player.cpp b/src/player.cpp
index f2ff59027..40d403952 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -100,6 +100,7 @@ Player::Player(IGameDef *gamedef):
Player::~Player()
{
+ clearHud();
}
// Horizontal acceleration (X and Z), Y direction is ignored
diff --git a/src/shader.cpp b/src/shader.cpp
index f855a7fe3..ef15f29ba 100644
--- a/src/shader.cpp
+++ b/src/shader.cpp
@@ -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,