fix for memory leak with weight painting and ensure vertex group is created before use.

This commit is contained in:
Campbell Barton 2012-12-28 09:00:05 +00:00
parent 4e5d5e0d84
commit 3f68790108
1 changed files with 10 additions and 2 deletions

View File

@ -405,7 +405,7 @@ static void free_vpaint_prev(VPaint *vp)
static void free_wpaint_prev(VPaint *vp)
{
if (vp->wpaint_prev) {
MEM_freeN(vp->wpaint_prev);
free_dverts(vp->wpaint_prev, vp->tot);
vp->wpaint_prev = NULL;
vp->tot = 0;
}
@ -2498,7 +2498,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot)
RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", "");
}
static int weight_paint_set_exec(bContext *C, wmOperator *UNUSED(op))
static int weight_paint_set_exec(bContext *C, wmOperator *op)
{
struct Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
@ -2506,6 +2506,10 @@ static int weight_paint_set_exec(bContext *C, wmOperator *UNUSED(op))
Brush *brush = paint_brush(&ts->wpaint->paint);
float vgroup_weight = BKE_brush_weight_get(scene, brush);
if (wpaint_ensure_data(C, op) == FALSE) {
return OPERATOR_CANCELLED;
}
wpaint_fill(scene->toolsettings->wpaint, obact, vgroup_weight);
ED_region_tag_redraw(CTX_wm_region(C)); /* XXX - should redraw all 3D views */
return OPERATOR_FINISHED;
@ -3217,6 +3221,10 @@ static int paint_weight_gradient_invoke(bContext *C, wmOperator *op, wmEvent *ev
{
int ret;
if (wpaint_ensure_data(C, op) == FALSE) {
return OPERATOR_CANCELLED;
}
ret = WM_gesture_straightline_invoke(C, op, event);
if (ret & OPERATOR_RUNNING_MODAL) {
struct ARegion *ar = CTX_wm_region(C);