Fix T57590: assert with zero length array buttons.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 18 Mar 2019 18:56:14 +0000 (19:56 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Mon, 18 Mar 2019 18:56:14 +0000 (19:56 +0100)
source/blender/editors/interface/interface_utils.c

index 7400e92..85eae9a 100644 (file)
@@ -61,9 +61,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
        switch (RNA_property_type(prop)) {
                case PROP_BOOLEAN:
                {
-                       int arraylen = RNA_property_array_length(ptr, prop);
-
-                       if (arraylen && index == -1)
+                       if (RNA_property_array_check(prop) && index == -1)
                                return NULL;
 
                        if (icon && name && name[0] == '\0')
@@ -77,9 +75,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
                case PROP_INT:
                case PROP_FLOAT:
                {
-                       int arraylen = RNA_property_array_length(ptr, prop);
-
-                       if (arraylen && index == -1) {
+                       if (RNA_property_array_check(prop) && index == -1) {
                                if (ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) {
                                        but = uiDefButR_prop(block, UI_BTYPE_COLOR, 0, name, x1, y1, x2, y2, ptr, prop, -1, 0, 0, -1, -1, NULL);
                                }