Fix crash in drawing socket names when zooming out a lot
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 27 Jul 2012 13:49:55 +0000 (13:49 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 27 Jul 2012 13:49:55 +0000 (13:49 +0000)
--
svn merge -r49291:49292 ^/branches/soc-2011-tomato

source/blender/editors/space_node/drawnode.c

index 6aec69ca61a96a4a7befde3fcbd2f4774531b294..ad3e1954e68ec2929685828ef27d502b107b8ec8 100644 (file)
@@ -217,16 +217,20 @@ static void node_draw_output_default(const bContext *C, uiBlock *block,
        float slen;
        int ofs = 0;
        const char *ui_name = IFACE_(name);
+       int len = strlen(ui_name);
        UI_ThemeColor(TH_TEXT);
        slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
-       while (slen > node->width) {
+       while (slen > node->width && ofs < len) {
                ofs++;
                slen = (UI_GetStringWidth(ui_name + ofs) + NODE_MARGIN_X) * snode->aspect_sqrt;
        }
-       uiDefBut(block, LABEL, 0, ui_name + ofs,
-                (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
-                (short)(node->width - NODE_DY), (short)NODE_DY,
-                NULL, 0, 0, 0, 0, "");
+
+       if (ofs < len) {
+               uiDefBut(block, LABEL, 0, ui_name + ofs,
+                        (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
+                        (short)(node->width - NODE_DY), (short)NODE_DY,
+                        NULL, 0, 0, 0, 0, "");
+       }
 
        (void)snode;
 }