Mem leak fixed in sound buffer & parent invert node
authorBenoit Bolsee <benoit.bolsee@online.be>
Sat, 1 Mar 2008 19:29:01 +0000 (19:29 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Sat, 1 Mar 2008 19:29:01 +0000 (19:29 +0000)
intern/SoundSystem/openal/SND_OpenALDevice.cpp
source/gameengine/SceneGraph/SG_IObject.cpp

index a278384dfd852df538009d2460c0972cc822b763..bb0204af53bd7751e49c7c0e903de6c66a4ea7ef 100644 (file)
@@ -332,12 +332,6 @@ SND_OpenALDevice::~SND_OpenALDevice()
 {
        MakeCurrent();
        
-       if (m_buffersinitialized)
-       {
-               alDeleteBuffers(NUM_BUFFERS, m_buffers);
-               m_buffersinitialized = false;
-       }
-       
        if (m_sourcesinitialized)
        {
                for (int i = 0; i < NUM_SOURCES; i++)
@@ -347,6 +341,12 @@ SND_OpenALDevice::~SND_OpenALDevice()
                m_sourcesinitialized = false;
        }
        
+       if (m_buffersinitialized)
+       {
+               alDeleteBuffers(NUM_BUFFERS, m_buffers);
+               m_buffersinitialized = false;
+       }
+       
        if (m_context) {
                MakeCurrent();
 #ifdef AL_VERSION_1_1
index 232ceb06958f02e3522e9a00824e3a327525cf81..4787847da0d9f6638293163936808c6a49408877 100644 (file)
@@ -128,6 +128,11 @@ ActivateDestructionCallback(
                // Call client provided destruction function on this!
                m_callbacks.m_destructionfunc(this,m_SGclientObject,m_SGclientInfo);
        }
+       else
+       {
+               // no callback but must still destroy the node to avoid memory leak
+               delete this;
+       }
 }
 
        void