Revision: 41294
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41294
Author: ender79
Date: 2011-10-26 13:24:58 +0000 (Wed, 26 Oct 2011)
Log Message:
-----------
Fix 28960: if BM_free_data_layer[_n] removed the last layer, we didn't clear
data->pool and instead kept it pointing to the pool that gets freed at the end
of update_data_blocks
Modified Paths:
--------------
branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
Modified: branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
2011-10-26 12:27:29 UTC (rev 41293)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/customdata.c
2011-10-26 13:24:58 UTC (rev 41294)
@@ -2333,7 +2333,13 @@
void CustomData_bmesh_init_pool(CustomData *data, int allocsize){
- if(data->totlayer)data->pool = BLI_mempool_create(data->totsize,
allocsize, allocsize, 1, 0);
+ /* Dispose old pools before calling here to avoid leaks */
+ BLI_assert(data->pool == NULL);
+
+ /* If there are no layers, no pool is needed just yet */
+ if (data->totlayer) {
+ data->pool = BLI_mempool_create(data->totsize, allocsize,
allocsize, 1, 0);
+ }
}
void CustomData_bmesh_merge(CustomData *source, CustomData *dest,
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
2011-10-26 12:27:29 UTC (rev 41293)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_interp.c
2011-10-26 13:24:58 UTC (rev 41294)
@@ -880,13 +880,16 @@
}
}
-
void BM_add_data_layer(BMesh *bm, CustomData *data, int type)
{
CustomData olddata;
olddata= *data;
olddata.layers= (olddata.layers)? MEM_dupallocN(olddata.layers): NULL;
+
+ /* the pool is now owned by olddata and must not be shared */
+ data->pool = NULL;
+
CustomData_add_layer(data, type, CD_DEFAULT, NULL, 0);
update_data_blocks(bm, &olddata, data);
@@ -899,6 +902,10 @@
olddata= *data;
olddata.layers= (olddata.layers)? MEM_dupallocN(olddata.layers): NULL;
+
+ /* the pool is now owned by olddata and must not be shared */
+ data->pool = NULL;
+
CustomData_add_layer_named(data, type, CD_DEFAULT, NULL, 0, name);
update_data_blocks(bm, &olddata, data);
@@ -911,6 +918,10 @@
olddata= *data;
olddata.layers= (olddata.layers)? MEM_dupallocN(olddata.layers): NULL;
+
+ /* the pool is now owned by olddata and must not be shared */
+ data->pool = NULL;
+
CustomData_free_layer_active(data, type, 0);
update_data_blocks(bm, &olddata, data);
@@ -923,6 +934,10 @@
olddata= *data;
olddata.layers= (olddata.layers)? MEM_dupallocN(olddata.layers): NULL;
+
+ /* the pool is now owned by olddata and must not be shared */
+ data->pool = NULL;
+
CustomData_free_layer(data, type, 0, CustomData_get_layer_index_n(data,
type, n));
update_data_blocks(bm, &olddata, data);
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs