[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49229] branches/soc-2012-swiss_cheese/ source/gameengine: Cleaning up a memory leak with KX_LibLoadStatus objects that were being sent to Python .
Mitchell Stokes
mogurijin at gmail.com
Wed Jul 25 23:06:13 CEST 2012
Revision: 49229
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49229
Author: moguri
Date: 2012-07-25 21:06:13 +0000 (Wed, 25 Jul 2012)
Log Message:
-----------
Cleaning up a memory leak with KX_LibLoadStatus objects that were being sent to Python. The objects are now saved to a map on the scene converter and deleted when the library is freed. This map can later be used to provide users with a list of status objects.
Modified Paths:
--------------
branches/soc-2012-swiss_cheese/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
branches/soc-2012-swiss_cheese/source/gameengine/Converter/KX_BlenderSceneConverter.h
branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_PythonInit.cpp
Modified: branches/soc-2012-swiss_cheese/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Converter/KX_BlenderSceneConverter.cpp 2012-07-25 20:51:04 UTC (rev 49228)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Converter/KX_BlenderSceneConverter.cpp 2012-07-25 21:06:13 UTC (rev 49229)
@@ -1175,6 +1175,7 @@
if (!(options & LIB_LOAD_ASYNC))
status->Finish();
+ m_status_map[main_newlib->name] = status;
return status;
}
@@ -1459,6 +1460,9 @@
/* make sure this maggie is removed from the import list if it's there (this operation is safe if it isn't in the list) */
removeImportMain(maggie);
+ delete m_status_map[maggie->name];
+ m_status_map.erase(maggie->name);
+
free_main(maggie);
return true;
Modified: branches/soc-2012-swiss_cheese/source/gameengine/Converter/KX_BlenderSceneConverter.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Converter/KX_BlenderSceneConverter.h 2012-07-25 20:51:04 UTC (rev 49228)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Converter/KX_BlenderSceneConverter.h 2012-07-25 21:06:13 UTC (rev 49229)
@@ -69,6 +69,9 @@
map<struct Material*, BL_Material*> m_mat_cache;
map<struct Material*, RAS_IPolyMaterial*> m_polymat_cache;
+ // Saved KX_LibLoadStatus objects
+ map<char *, class KX_LibLoadStatus*> m_status_map;
+
// Should also have a list of collision shapes.
// For the time being this is held in KX_Scene::m_shapes
Modified: branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
--- branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_PythonInit.cpp 2012-07-25 20:51:04 UTC (rev 49228)
+++ branches/soc-2012-swiss_cheese/source/gameengine/Ketsji/KX_PythonInit.cpp 2012-07-25 21:06:13 UTC (rev 49229)
@@ -705,7 +705,7 @@
BLI_path_abs(abs_path, gp_GamePythonPath);
if ((status=kx_scene->GetSceneConverter()->LinkBlendFilePath(abs_path, group, kx_scene, &err_str, options))) {
- return status->NewProxy(false);
+ return status->GetProxy();
}
}
else
@@ -713,7 +713,7 @@
if ((status=kx_scene->GetSceneConverter()->LinkBlendFileMemory(py_buffer.buf, py_buffer.len, path, group, kx_scene, &err_str, options))) {
PyBuffer_Release(&py_buffer);
- return status->NewProxy(false);
+ return status->GetProxy();
}
PyBuffer_Release(&py_buffer);
More information about the Bf-blender-cvs
mailing list