UI: don't draw outline when it's not calculated
authorCampbell Barton <ideasman42@gmail.com>
Thu, 11 Jan 2018 02:20:08 +0000 (13:20 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 11 Jan 2018 02:23:55 +0000 (13:23 +1100)
Outline drawing was running even when there were no verts to draw.
Causes an assert in 2.8.

source/blender/editors/interface/interface_widgets.c

index 39ee8e2885d9cf387ff8d021b11368c1515fc5a3..b25e1130c60fde16848ba90e07e5409a093f4172 100644 (file)
@@ -685,6 +685,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
 
        /* backdrop non AA */
        if (wtb->draw_inner) {
+               BLI_assert(wtb->totvert != 0);
                if (wcol->shaded == 0) {
                        if (wcol->alpha_check) {
                                float inner_v_half[WIDGET_SIZE_MAX][2];
@@ -764,6 +765,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
        
        /* for each AA step */
        if (wtb->draw_outline) {
+               BLI_assert(wtb->totvert != 0);
                float triangle_strip[WIDGET_SIZE_MAX * 2 + 2][2]; /* + 2 because the last pair is wrapped */
                float triangle_strip_emboss[WIDGET_SIZE_MAX * 2][2]; /* only for emboss */
 
@@ -2680,6 +2682,10 @@ static void widget_numbut_draw(uiWidgetColors *wcol, rcti *rect, int state, int
        if (!emboss) {
                round_box_edges(&wtb, roundboxalign, rect, rad);
        }
+       else {
+               wtb.draw_inner = false;
+               wtb.draw_outline = false;
+       }
 
        /* decoration */
        if (!(state & UI_STATE_TEXT_INPUT)) {