Commit: 1d9e69f1463f01ab2242b05cb6a0486a6f9eaeaf
Author: Campbell Barton
Date:   Fri Aug 29 16:56:19 2014 +1000
Branches: master
https://developer.blender.org/rB1d9e69f1463f01ab2242b05cb6a0486a6f9eaeaf

Fix T41617: Color ramp crashes user preferences

Color ramps with no handles caused issues.

===================================================================

M       source/blender/blenkernel/intern/texture.c
M       source/blender/editors/interface/interface_draw.c
M       source/blender/editors/interface/interface_handlers.c

===================================================================

diff --git a/source/blender/blenkernel/intern/texture.c 
b/source/blender/blenkernel/intern/texture.c
index 4d5c7dc..b1981a3 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -512,19 +512,18 @@ CBData *colorband_element_add(struct ColorBand *coba, 
float position)
        if (coba->tot == MAXCOLORBAND) {
                return NULL;
        }
-       else if (coba->tot > 0) {
+       else {
                CBData *xnew;
-               float col[4];
-
-               do_colorband(coba, position, col);
 
                xnew = &coba->data[coba->tot];
                xnew->pos = position;
 
-               xnew->r = col[0];
-               xnew->g = col[1];
-               xnew->b = col[2];
-               xnew->a = col[3];
+               if (coba->tot != 0) {
+                       do_colorband(coba, position, &xnew->r);
+               }
+               else {
+                       zero_v4(&xnew->r);
+               }
        }
 
        coba->tot++;
diff --git a/source/blender/editors/interface/interface_draw.c 
b/source/blender/editors/interface/interface_draw.c
index 15b8494..235d765 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1151,9 +1151,11 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors 
*UNUSED(wcol), const rcti
        }
 
        /* layer: active handle */
-       cbd = &coba->data[coba->cur];
-       pos = x1 + cbd->pos * (sizex - 1) + 1;
-       ui_draw_colorband_handle(rect, pos, &cbd->r, display, true);
+       if (coba->tot != 0) {
+               cbd = &coba->data[coba->cur];
+               pos = x1 + cbd->pos * (sizex - 1) + 1;
+               ui_draw_colorband_handle(rect, pos, &cbd->r, display, true);
+       }
 }
 
 void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index 166090c..2d919a2 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -5020,6 +5020,9 @@ static bool ui_numedit_but_COLORBAND(uiBut *but, 
uiHandleButtonData *data, int m
        if (data->draglastx == mx)
                return changed;
 
+       if (data->coba->tot == 0)
+               return changed;
+
        dx = ((float)(mx - data->draglastx)) / BLI_rctf_size_x(&but->rect);
        data->dragcbd->pos += dx;
        CLAMP(data->dragcbd->pos, 0.0f, 1.0f);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to