fix for own bug - memory leak when cancelling weight gradient tool
This commit is contained in:
parent
2013934878
commit
0ac2f6e7d7
|
@ -56,6 +56,7 @@ void defvert_remove_group(struct MDeformVert *dvert, struct
|
|||
void defvert_clear(struct MDeformVert *dvert);
|
||||
int defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b);
|
||||
|
||||
void BKE_defvert_array_free_elems(struct MDeformVert *dvert, int totvert);
|
||||
void BKE_defvert_array_free(struct MDeformVert *dvert, int totvert);
|
||||
void BKE_defvert_array_copy(struct MDeformVert *dst, const struct MDeformVert *src, int totvert);
|
||||
|
||||
|
|
|
@ -809,7 +809,7 @@ void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int copyco
|
|||
|
||||
}
|
||||
|
||||
void BKE_defvert_array_free(MDeformVert *dvert, int totvert)
|
||||
void BKE_defvert_array_free_elems(MDeformVert *dvert, int totvert)
|
||||
{
|
||||
/* Instead of freeing the verts directly,
|
||||
* call this function to delete any special
|
||||
|
@ -823,6 +823,18 @@ void BKE_defvert_array_free(MDeformVert *dvert, int totvert)
|
|||
for (i = 0; i < totvert; i++) {
|
||||
if (dvert[i].dw) MEM_freeN(dvert[i].dw);
|
||||
}
|
||||
MEM_freeN(dvert);
|
||||
}
|
||||
|
||||
void BKE_defvert_array_free(MDeformVert *dvert, int totvert)
|
||||
{
|
||||
/* Instead of freeing the verts directly,
|
||||
* call this function to delete any special
|
||||
* vert data */
|
||||
if (!dvert)
|
||||
return;
|
||||
|
||||
/* Free any special data from the verts */
|
||||
BKE_defvert_array_free_elems(dvert, totvert);
|
||||
|
||||
MEM_freeN(dvert);
|
||||
}
|
||||
|
|
|
@ -3182,6 +3182,7 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, wmEvent *eve
|
|||
VPaint *wp = ts->wpaint;
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Mesh *me = ob->data;
|
||||
BKE_defvert_array_free_elems(me->dvert, me->totvert);
|
||||
BKE_defvert_array_copy(me->dvert, wp->wpaint_prev, me->totvert);
|
||||
free_wpaint_prev(wp);
|
||||
|
||||
|
|
Loading…
Reference in New Issue