From 11b994e26e4dbfc40dc6ff2194b7855e2eb20f23 Mon Sep 17 00:00:00 2001 From: mano-wii Date: Thu, 25 Jul 2019 17:06:53 -0300 Subject: [PATCH] Fix T67671: Blender crashes when resizing sidebar with a colorbamp The amount of triangles drawn by the button depends on its `sizex`. See: ``` immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2); ``` Therefore the `sizex` cannot be 0. Solution a bit similar to rB56b0cd1d. Ref T67671 Reviewers: fclem, brecht Maniphest Tasks: T67671 Differential Revision: https://developer.blender.org/D5347 --- source/blender/editors/interface/interface_draw.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 7afdbe9d266..6a36bf364a3 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1606,6 +1606,11 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const float sizey_solid = sizey * 0.25f; float y1 = rect->ymin; + /* exit early if too narrow */ + if (sizex <= 0) { + return; + } + GPUVertFormat *format = immVertexFormat(); pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);