From 674f23c5361f249e28d6cf60daec6b213b0bf20b Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 3 May 2007 19:11:54 +0000 Subject: [PATCH] == Sculpt Mode == Fixed bug #6639 ] Sculpt mode clearing brush texture causes a crash (null pointer) * Added code to clear the brush texture preview (used for propset) when deleting a brush texture * Added a check in tex_strength() for an empty (NULL) texture slot to prevent the crash --- source/blender/src/sculptmode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index 2d21802d548..7c3b8b69e24 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -309,9 +309,15 @@ void sculptmode_rem_tex(void *junk0,void *junk1) { MTex *mtex= G.scene->sculptdata.mtex[G.scene->sculptdata.texact]; if(mtex) { + SculptSession *ss= sculpt_session(); if(mtex->tex) mtex->tex->id.us--; MEM_freeN(mtex); G.scene->sculptdata.mtex[G.scene->sculptdata.texact]= NULL; + /* Clear brush preview */ + if(ss->texcache) { + MEM_freeN(ss->texcache); + ss->texcache= NULL; + } BIF_undo_push("Unlink brush texture"); allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWOOPS, 0); @@ -783,7 +789,7 @@ float tex_strength(EditData *e, float *point, const float len,const unsigned vin SculptSession *ss= sculpt_session(); float avg= 1; - if(sd->texact==-1) + if(sd->texact==-1 || !sd->mtex[sd->texact]) avg= 1; else if(sd->texrept==SCULPTREPT_3D) { /* Get strength by feeding the vertex location directly