fix memory leak
authorsapier <Sapier at GMX dot net>
Sun, 31 Mar 2013 19:59:00 +0000 (19:59 +0000)
committerkwolekr <kwolekr@minetest.net>
Sat, 6 Apr 2013 16:00:36 +0000 (12:00 -0400)
src/tile.cpp

index aea9665f5eb69ca3568c12447538a81e7a1b8771..c5e8a2a9dfc354af64eaca9c26a704a91188e02b 100644 (file)
@@ -826,7 +826,7 @@ void TextureSource::rebuildImagesAndTextures()
                video::ITexture *t = NULL;
                if(img)
                        t = driver->addTexture(sap->name.c_str(), img);
-               
+               video::ITexture *t_old = sap->a.atlas;
                // Replace texture
                sap->a.atlas = t;
                sap->a.pos = v2f(0,0);
@@ -835,6 +835,9 @@ void TextureSource::rebuildImagesAndTextures()
                sap->atlas_img = img;
                sap->intpos = v2s32(0,0);
                sap->intsize = img->getDimension();
+
+               if (t_old != 0)
+                       driver->removeTexture(t_old);
        }
 }