Commit: ec305ea91fd57302e44297c1d9bc9a9771ee6376
Author: Dalai Felinto
Date:   Thu Oct 18 14:40:27 2018 +0000
Branches: blender2.8
https://developer.blender.org/rBec305ea91fd57302e44297c1d9bc9a9771ee6376

Fix assert/crash when copying RGBA color into RGB

For example, copy from viewport display color into brush color.

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

M       source/blender/editors/interface/interface_handlers.c

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

diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index b883984a702..3f55cd5d731 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -2214,11 +2214,17 @@ static void ui_but_paste_color(bContext *C, uiBut *but, 
char *buf_paste)
 {
        float rgba[4];
        if (parse_float_array(buf_paste, rgba, 4)) {
-               /* assume linear colors in buffer */
-               if (but->rnaprop && RNA_property_subtype(but->rnaprop) == 
PROP_COLOR_GAMMA) {
-                       linearrgb_to_srgb_v3_v3(rgba, rgba);
+               if (but->rnaprop) {
+                       /* Assume linear colors in buffer. */
+                       if (RNA_property_subtype(but->rnaprop) == 
PROP_COLOR_GAMMA) {
+                               linearrgb_to_srgb_v3_v3(rgba, rgba);
+                       }
+
+                       /* Some color properties are RGB, not RGBA. */
+                       int array_len = get_but_property_array_length(but);
+                       BLI_assert(ELEM(array_len, 3, 4));
+                       ui_but_set_float_array(C, but, NULL, rgba, array_len);
                }
-               ui_but_set_float_array(C, but, NULL, rgba, 4);
        }
        else {
                WM_report(RPT_ERROR, "Paste expected 4 numbers, formatted: '[n, 
n, n, n]'");

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

Reply via email to