fix mesh leak in camera class
authorsapier <Sapier at GMX dot net>
Sun, 7 Apr 2013 18:33:00 +0000 (20:33 +0200)
committerkwolekr <kwolekr@minetest.net>
Mon, 8 Apr 2013 01:49:55 +0000 (21:49 -0400)
src/camera.cpp
src/camera.h

index 138b022c049208ec07a788e8daa7db15310e5f0d..735a8d1e9558653a3b7cbbdb4f727e2b0cdda026 100644 (file)
@@ -69,7 +69,8 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
        m_view_bobbing_speed(0),
 
        m_digging_anim(0),
-       m_digging_button(-1)
+       m_digging_button(-1),
+       m_dummymesh(createCubeMesh(v3f(1,1,1)))
 {
        //dstream<<__FUNCTION_NAME<<std::endl;
 
@@ -84,13 +85,14 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control,
        // all other 3D scene nodes and before the GUI.
        m_wieldmgr = smgr->createNewSceneManager();
        m_wieldmgr->addCameraSceneNode();
-       m_wieldnode = m_wieldmgr->addMeshSceneNode(createCubeMesh(v3f(1,1,1)), NULL);  // need a dummy mesh
+       m_wieldnode = m_wieldmgr->addMeshSceneNode(m_dummymesh, NULL);  // need a dummy mesh
 }
 
 Camera::~Camera()
 {
-       m_wieldnode->setMesh(NULL);
        m_wieldmgr->drop();
+
+       delete m_dummymesh;
 }
 
 bool Camera::successfullyCreated(std::wstring& error_message)
index fc43d1176496d7ea6a3a4b0894fc68331228c0b0..989dcb71836e52ef3cd0224b2ceee86aef63a65f 100644 (file)
@@ -173,6 +173,9 @@ private:
        // If 0, left-click digging animation
        // If 1, right-click digging animation
        s32 m_digging_button;
+
+       //dummymesh for camera
+       irr::scene::IAnimatedMesh* m_dummymesh;
 };
 
 #endif