diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-09-14 09:44:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-09-14 09:44:47 +0400 |
commit | f6c7a69565153f65e49a0f6421ad04d23cdd946a (patch) | |
tree | 0fcc6ce4607949dd0f667111a247516ec3e2228d /source/blender | |
parent | b31a88ccf0e06ac9f7efb43e18c2a7b0fcf40ac4 (diff) |
code cleanup: correct misleading use of LABEL button type.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 19 |
3 files changed, 20 insertions, 14 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index ecf0f9f8c2f..c6f58fdd70b 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -196,7 +196,7 @@ typedef enum { UI_BUT_POIN_BIT = 256 /* OR'd with a bit index*/ } eButPointerType; -/* button requires a pointer */ +/* requires (but->poin != NULL) */ #define UI_BUT_POIN_TYPES (UI_BUT_POIN_FLOAT | UI_BUT_POIN_SHORT | UI_BUT_POIN_CHAR) /* assigned to but->type, OR'd with the flags above when passing args */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 61e8fc38a04..aef20245676 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2592,10 +2592,17 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, { uiBut *but; int slen; - - if (type & UI_BUT_POIN_TYPES) { /* a pointer is required */ - if (poin == NULL) + + /* we could do some more error checks here */ + if ((type & BUTTYPE) == LABEL) { + BLI_assert((poin != NULL || a1 != 0.0f || a2 != 0.0f || min != 0.0f || max != 0.0f) == FALSE); + } + + if (type & UI_BUT_POIN_TYPES) { /* a pointer is required */ + if (poin == NULL) { + BLI_assert(0); return NULL; + } } but = MEM_callocN(sizeof(uiBut), "uiBut"); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index bdd1bcc7253..5ebcef1d9a7 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -647,23 +647,22 @@ static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), v static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock, int in_out, float xoffset, float yoffset) { - bNodeTree *ngroup = (bNodeTree *)gnode->id; - uiBut *bt; - const char *ui_name = IFACE_(sock->name); - if (sock->flag & SOCK_DYNAMIC) { - bt = uiDefBut(gnode->block, TEX, 0, "", - sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY, - sock->name, 0, sizeof(sock->name), 0, 0, ""); + bNodeTree *ngroup = (bNodeTree *)gnode->id; + uiBut *but; + but = uiDefBut(gnode->block, TEX, 0, "", + sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY, + sock->name, 0, sizeof(sock->name), 0, 0, ""); if (in_out == SOCK_IN) - uiButSetFunc(bt, update_group_input_cb, snode, ngroup); + uiButSetFunc(but, update_group_input_cb, snode, ngroup); else - uiButSetFunc(bt, update_group_output_cb, snode, ngroup); + uiButSetFunc(but, update_group_output_cb, snode, ngroup); } else { + const char *ui_name = IFACE_(sock->name); uiDefBut(gnode->block, LABEL, 0, ui_name, sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY, - NULL, 0, sizeof(ui_name), 0, 0, ""); + NULL, 0, 0, 0, 0, ""); } } |