Make sure matcap icons are within range.
authorAntony Riakiotakis <kalast@gmail.com>
Mon, 23 Mar 2015 11:00:34 +0000 (12:00 +0100)
committerAntony Riakiotakis <kalast@gmail.com>
Mon, 23 Mar 2015 11:00:34 +0000 (12:00 +0100)
Basically out of range could happen when opening files made in 2.72 when
the new icons for texture painting were added. Apparently some more
caution is needed here.

source/blender/editors/space_view3d/drawobject.c
source/blender/makesrna/intern/rna_space.c

index 61c9891e2011453156238f237fa3eb7eb2860d43..d4d8db6d6c7262db38c2938226d472583397172a 100644 (file)
@@ -7232,8 +7232,11 @@ static void draw_object_matcap_check(View3D *v3d, Object *ob)
                v3d->defmaterial->preview = NULL;
        }
        /* first time users */
-       if (v3d->matcap_icon == 0)
+       if (v3d->matcap_icon < ICON_MATCAP_01 ||
+           v3d->matcap_icon > ICON_MATCAP_24)
+       {
                v3d->matcap_icon = ICON_MATCAP_01;
+       }
 
        if (v3d->defmaterial->preview == NULL)
                v3d->defmaterial->preview = UI_icon_to_preview(v3d->matcap_icon);
index db4b097b9c39de7b73bf2d341330b1dbc08d2cd4..8e262df7e67c0d1477f4b946e74aa54f8ed4b492 100644 (file)
@@ -493,8 +493,11 @@ static void rna_SpaceView3D_matcap_enable(Main *UNUSED(bmain), Scene *UNUSED(sce
 {
        View3D *v3d = (View3D *)(ptr->data);
        
-       if (v3d->matcap_icon == 0)
+       if (v3d->matcap_icon < ICON_MATCAP_01 ||
+           v3d->matcap_icon > ICON_MATCAP_24)
+       {
                v3d->matcap_icon = ICON_MATCAP_01;
+       }
 }
 
 static void rna_SpaceView3D_pivot_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)