[Bf-committers] Fix for crashing blender if no material

Meino Christian Cramer bf-committers@blender.org
Sun, 16 Nov 2003 09:12:54 +0100 (CET)


Hi Ton, hi Blenderixx ! ;)

 Sorry for using this way to submit a patch for fixing a bug in 
 blender, but my problem to log into the bugtracker or into the
 www.blender.org still remain. I dont know whether this is due to
 a bug in my browser, in my proxy, in my firewall or ... ???

 Recent snapshots of blender (cvs) do crash if the material buttons
 are entered, while an object is active, which has no material or 
 while the material buttons are active while switching to an object
 with no material. 

 I found a way to avoid this crashing. Be warned! This are my first
 steps into the blender source! The only thing I can say is: 
 For me it works.... ;)

 here is the patch :

-------------------

 diff -ur blender/source/blender/src/buttons_shading.c blendernocrash/source/blender/src/buttons_shading.c
--- blender/source/blender/src/buttons_shading.c	2003-11-15 00:35:35.000000000 +0100
+++ blendernocrash/source/blender/src/buttons_shading.c	2003-11-16 08:55:38.000000000 +0100
@@ -2295,8 +2295,11 @@
 	
 	/* indicate which one is linking a material */
 	uiBlockBeginAlign(block);
+    
+    if( id == NULL ) return;
+
 	uiSetButLock(id->lib!=0, "Can't edit library data");
-	
+
 	strncpy(str, id->name, 2);
 	str[2]= ':'; str[3]= 0;
 	but= uiDefBut(block, TEX, B_IDNAME, str,		8,174,115,20, id->name+2, 0.0, 18.0, 0, 0, "Show the block the material is linked to");
@@ -2321,7 +2324,7 @@
 	uiBlockEndAlign(block);
 	
 	if(ob->totcol==0) return;
-
+    
 	ma= give_current_material(ob, ob->actcol);	
 	if(ma==0) return;	
 
-------------------------

 Kind regards and thank you for making blender such a great program !
 Meino (mcc)