[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53332] trunk/blender/source/blender/ blenkernel/intern/material.c: Bugfix #33667
Ton Roosendaal
ton at blender.org
Wed Dec 26 18:36:52 CET 2012
Revision: 53332
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53332
Author: ton
Date: 2012-12-26 17:36:51 +0000 (Wed, 26 Dec 2012)
Log Message:
-----------
Bugfix #33667
Mesh had invalid face indices (number too high).
On Separate in Edit Mode it crashed.
Two fixes:
- The Material properties viewer just showed the last material in the index array.
Now it shows nothing, to indicate it's an invalid selected material.
- Crash was caused by array copy magic, not checking the active index properly.
(No assert, no warning prints, I think cases like this can happen too easily, and this
way user gets notified nicely and can fix it).
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/material.c
Modified: trunk/blender/source/blender/blenkernel/intern/material.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/material.c 2012-12-26 16:42:47 UTC (rev 53331)
+++ trunk/blender/source/blender/blenkernel/intern/material.c 2012-12-26 17:36:51 UTC (rev 53332)
@@ -628,11 +628,14 @@
if (totcolp == NULL || ob->totcol == 0) return NULL;
if (act < 0) {
- printf("no!\n");
+ printf("Negative material index!\n");
}
- if (act > ob->totcol) act = ob->totcol;
- else if (act <= 0) act = 1;
+ /* return NULL for invalid 'act', can happen for mesh face indices */
+ if (act > ob->totcol)
+ return NULL;
+ else if (act <= 0)
+ return NULL;
if (ob->matbits && ob->matbits[act - 1]) { /* in object */
ma = ob->mat[act - 1];
@@ -1234,6 +1237,11 @@
if (*matarar == NULL) return FALSE;
+ /* can happen on face selection in editmode */
+ if (ob->actcol > ob->totcol) {
+ ob->actcol = ob->totcol;
+ }
+
/* we delete the actcol */
mao = (*matarar)[ob->actcol - 1];
if (mao) mao->id.us--;
More information about the Bf-blender-cvs
mailing list