Fix T45060: Brush size snaps back to default max
authorCampbell Barton <ideasman42@gmail.com>
Mon, 15 Jun 2015 12:26:19 +0000 (22:26 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 15 Jun 2015 12:27:52 +0000 (22:27 +1000)
source/blender/windowmanager/intern/wm_operators.c

index 28cb01aa4a3dce7190dd34d1c61a2e3f86674428..c69dc9de05b786727108634f5803c0524b22cd22 100644 (file)
@@ -4256,8 +4256,7 @@ static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *eve
 {
        wmWindowManager *wm;
        RadialControl *rc;
-       int min_value_int, max_value_int, step_int;
-       float step_float, precision;
+
 
        if (!(op->customdata = rc = MEM_callocN(sizeof(RadialControl), "RadialControl")))
                return OPERATOR_CANCELLED;
@@ -4270,17 +4269,29 @@ static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *eve
        /* get type, initial, min, and max values of the property */
        switch ((rc->type = RNA_property_type(rc->prop))) {
                case PROP_INT:
-                       rc->initial_value = RNA_property_int_get(&rc->ptr, rc->prop);
-                       RNA_property_int_ui_range(&rc->ptr, rc->prop, &min_value_int,
-                                                 &max_value_int, &step_int);
-                       rc->min_value = min_value_int;
-                       rc->max_value = max_value_int;
+               {
+                       int value, min, max, step;
+
+                       value = RNA_property_int_get(&rc->ptr, rc->prop);
+                       RNA_property_int_ui_range(&rc->ptr, rc->prop, &min, &max, &step);
+
+                       rc->initial_value = value;
+                       rc->min_value = min_ii(value, min);
+                       rc->max_value = max_ii(value, max);
                        break;
+               }
                case PROP_FLOAT:
-                       rc->initial_value = RNA_property_float_get(&rc->ptr, rc->prop);
-                       RNA_property_float_ui_range(&rc->ptr, rc->prop, &rc->min_value,
-                                                   &rc->max_value, &step_float, &precision);
+               {
+                       float value, min, max, step, precision;
+
+                       value = RNA_property_float_get(&rc->ptr, rc->prop);
+                       RNA_property_float_ui_range(&rc->ptr, rc->prop, &min, &min, &step, &precision);
+
+                       rc->initial_value = value;
+                       rc->min_value = min_ff(value, min);
+                       rc->max_value = max_ff(value, max);
                        break;
+               }
                default:
                        BKE_report(op->reports, RPT_ERROR, "Property must be an integer or a float");
                        MEM_freeN(rc);