diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-12-20 13:50:40 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-12-20 13:50:40 +0300 |
commit | 4d16275c0369fb3857d3240af55318572c4b9813 (patch) | |
tree | 2be4c3552029181f9f01d78b1a26854aea03db9c /source/blender/editors | |
parent | 170c464920bdbbd4e7db3ff2b84c8550740eb2cc (diff) |
Bugfix #20173: Crash with Weight Paint on polygons with no faces
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index ba9c3631728..cddfad19fa7 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1438,22 +1438,35 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P VPaint *wp= ts->wpaint; Brush *brush = paint_brush(&wp->paint); struct WPaintData *wpd= paint_stroke_mode_data(stroke); - ViewContext *vc= &wpd->vc; - Object *ob= vc->obact; - Mesh *me= ob->data; + ViewContext *vc; + Object *ob; + Mesh *me; float mat[4][4]; float paintweight= ts->vgroup_weight; - int *indexar= wpd->indexar; + int *indexar; int totindex, index, totw, flip; float alpha; float mval[2], pressure; - + + /* cannot paint if there is no stroke data */ + if (wpd == NULL) { + // XXX: force a redraw here, since even though we can't paint, + // at least view won't freeze until stroke ends + ED_region_tag_redraw(CTX_wm_region(C)); + return; + } + + vc= &wpd->vc; + ob= vc->obact; + me= ob->data; + indexar= wpd->indexar; + view3d_operator_needs_opengl(C); - + /* load projection matrix */ wmMultMatrix(ob->obmat); wmGetSingleMatrix(mat); - wmLoadMatrix(wpd->vc.rv3d->viewmat); + wmLoadMatrix(vc->rv3d->viewmat); flip = RNA_boolean_get(itemptr, "flip"); pressure = RNA_float_get(itemptr, "pressure"); @@ -1598,13 +1611,17 @@ static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) Object *ob= CTX_data_active_object(C); struct WPaintData *wpd= paint_stroke_mode_data(stroke); - if(wpd->vertexcosnos) - MEM_freeN(wpd->vertexcosnos); - MEM_freeN(wpd->indexar); + if(wpd) { + if(wpd->vertexcosnos) + MEM_freeN(wpd->vertexcosnos); + MEM_freeN(wpd->indexar); + + if (wpd->vgroup_validmap) + MEM_freeN(wpd->vgroup_validmap); + + MEM_freeN(wpd); + } - if (wpd->vgroup_validmap) - MEM_freeN(wpd->vgroup_validmap); - /* frees prev buffer */ copy_wpaint_prev(ts->wpaint, NULL, 0); @@ -1623,9 +1640,7 @@ static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) } } - DAG_id_flush_update(ob->data, OB_RECALC_DATA); - - MEM_freeN(wpd); + DAG_id_flush_update(ob->data, OB_RECALC_DATA); } |