[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24611] trunk/blender/source/blender/ makesrna/intern/rna_sculpt_paint.c: switching the active brush with Alt+Wheel would crash when going past the last , need rna to clamp the range.

Campbell Barton ideasman42 at gmail.com
Tue Nov 17 16:10:19 CET 2009


Revision: 24611
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24611
Author:   campbellbarton
Date:     2009-11-17 16:10:19 +0100 (Tue, 17 Nov 2009)

Log Message:
-----------
switching the active brush with Alt+Wheel would crash when going past the last, need rna to clamp the range.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c	2009-11-17 14:32:19 UTC (rev 24610)
+++ trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c	2009-11-17 15:10:19 UTC (rev 24611)
@@ -142,6 +142,21 @@
 
 	return (edit && edit->psys);
 }
+
+static void rna_Paint_active_brush_index_set(PointerRNA *ptr, int value)
+{
+	Paint *p= ptr->data;
+	CLAMP(value, 0, p->brush_count-1);
+	p->active_brush_index= value;
+}
+
+static void rna_Paint_active_brush_index_range(PointerRNA *ptr, int *min, int *max)
+{
+	Paint *p= ptr->data;
+	*min= 0;
+	*max= MAX2(p->brush_count-1, 0);
+}
+
 #else
 
 static void rna_def_paint(BlenderRNA *brna)
@@ -162,7 +177,8 @@
 	RNA_def_property_ui_text(prop, "Brushes", "Brushes selected for this paint mode.");
 
 	prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE);
-	RNA_def_property_range(prop, 0, INT_MAX);       
+	RNA_def_property_int_funcs(prop, NULL, "rna_Paint_active_brush_index_set", "rna_Paint_active_brush_index_range");
+	RNA_def_property_range(prop, 0, INT_MAX);
 
 	/* Fake property to get active brush directly, rather than integer index */
 	prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);





More information about the Bf-blender-cvs mailing list