fix [#32518] Vertex slide crash sometimes.

Undo would leave BMEditMesh->me pointer NULL, this would likely crash EDBM_verts_mirror_cache_begin() too.

Rather then restore 'me', remove the pointer altogether and use BMEditMesh->ob->data to save us having to keep track of 2 pointers.
This commit is contained in:
Campbell Barton 2012-09-10 03:42:29 +00:00
parent 2812dd92cf
commit e647c748fb
4 changed files with 11 additions and 9 deletions

@ -72,10 +72,12 @@ typedef struct BMEditMesh {
short selectmode;
short mat_nr;
/*Mesh structure this editmesh came from, if it came from one*/
struct Mesh *me;
/* Object this editmesh came from (if it came from one) */
struct Object *ob;
/* Unused for now, we could bring it back and assign in the same way 'ob' is */
// struct Mesh *me;
/*temp variables for x-mirror editing*/
int mirror_cdlayer; /* -1 is invalid */
int mirr_free_arrays;

@ -1747,10 +1747,11 @@ DerivedMesh *getEditDerivedBMesh(BMEditMesh *em,
BMEditMesh *BMEdit_FromObject(Object *ob)
{
BLI_assert(ob->type == OB_MESH);
/* sanity check */
#ifndef NDEBUG
// if (((Mesh *)ob->data)->edit_btmesh) {
// BLI_assert(((Mesh *)ob->data)->edit_btmesh->me == ob->data);
// }
if (((Mesh *)ob->data)->edit_btmesh) {
BLI_assert(((Mesh *)ob->data)->edit_btmesh->ob == ob);
}
#endif
return ((Mesh *)ob->data)->edit_btmesh;
}

@ -208,7 +208,7 @@ static void vtx_slide_confirm(bContext *C, wmOperator *op)
other = BM_edge_other_vert(vso->sel_edge, vso->start_vtx);
}
if (em->me->editflag & ME_EDIT_MIRROR_X) {
if (((Mesh *)em->ob->data)->editflag & ME_EDIT_MIRROR_X) {
EDBM_verts_mirror_cache_begin(em, TRUE);
mirr_vtx = EDBM_verts_mirror_get(em, vso->start_vtx);
@ -255,7 +255,7 @@ static void vtx_slide_confirm(bContext *C, wmOperator *op)
BM_select_history_store(em->bm, vso->start_vtx);
}
if (em->me->editflag & ME_EDIT_MIRROR_X) {
if (((Mesh *)em->ob->data)->editflag & ME_EDIT_MIRROR_X) {
EDBM_verts_mirror_cache_end(em);
}

@ -345,7 +345,6 @@ void EDBM_mesh_make(ToolSettings *ts, Scene *UNUSED(scene), Object *ob)
me->edit_btmesh->selectmode = me->edit_btmesh->bm->selectmode = ts->selectmode;
me->edit_btmesh->mat_nr = (ob->actcol > 0) ? ob->actcol - 1 : 0;
me->edit_btmesh->me = me;
me->edit_btmesh->ob = ob;
}
@ -1056,7 +1055,7 @@ static BMVert *cache_mirr_intptr_as_bmvert(intptr_t *index_lookup, int index)
#define BM_CD_LAYER_ID "__mirror_index"
void EDBM_verts_mirror_cache_begin(BMEditMesh *em, const short use_select)
{
Mesh *me = em->me;
Mesh *me = (Mesh *)em->ob->data;
BMesh *bm = em->bm;
BMIter iter;
BMVert *v;