diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-11-07 13:02:29 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-11-07 13:02:29 +0400 |
commit | 9708f7921d3c865107f371349dc2a6726775f92c (patch) | |
tree | 091f5f681413c655e30b8f8dc4de176303fe55fa /source | |
parent | be09e694b1a983b2aeb158290bb6dc831e1b8622 (diff) |
Cleanup: nice bool return value from ed_node_link_conditions function instead of using the space pointer for this.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_node/node_relationships.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 4304ee6c418..23ecb87151b 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -1173,52 +1173,57 @@ void NODE_OT_detach(wmOperatorType *ot) /* prevent duplicate testing code below */ -static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) +static bool ed_node_link_conditions(ScrArea *sa, SpaceNode **r_snode, bNode **r_select) { SpaceNode *snode = sa ? sa->spacedata.first : NULL; - bNode *node; + bNode *node, *select = NULL; bNodeLink *link; - /* no unlucky accidents */ - if (sa == NULL || sa->spacetype != SPACE_NODE) return NULL; + *r_snode = snode; + *r_select = NULL; - *select = NULL; + /* no unlucky accidents */ + if (sa == NULL || sa->spacetype != SPACE_NODE) + return false; for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (*select) + if (select) break; else - *select = node; + select = node; } } /* only one selected */ - if (node || *select == NULL) return NULL; + if (node || select == NULL) + return false; /* correct node */ - if ((*select)->inputs.first == NULL || (*select)->outputs.first == NULL) return NULL; + if (select->inputs.first == NULL || select->outputs.first == NULL) + return false; /* test node for links */ for (link = snode->edittree->links.first; link; link = link->next) { if (nodeLinkIsHidden(link)) continue; - if (link->tonode == *select || link->fromnode == *select) - return NULL; + if (link->tonode == select || link->fromnode == select) + return false; } - return snode; + *r_select = select; + return true; } /* test == 0, clear all intersect flags */ void ED_node_link_intersect_test(ScrArea *sa, int test) { bNode *select; - SpaceNode *snode = ed_node_link_conditions(sa, &select); + SpaceNode *snode; bNodeLink *link, *selink = NULL; float mcoords[6][2]; - if (snode == NULL) return; + if (!ed_node_link_conditions(sa, &snode, &select)) return; /* clear flags */ for (link = snode->edittree->links.first; link; link = link->next) @@ -1293,11 +1298,11 @@ static bNodeSocket *socket_best_match(ListBase *sockets) void ED_node_link_insert(ScrArea *sa) { bNode *node, *select; - SpaceNode *snode = ed_node_link_conditions(sa, &select); + SpaceNode *snode; bNodeLink *link; bNodeSocket *sockto; - if (snode == NULL) return; + if (!ed_node_link_conditions(sa, &snode, &select)) return; /* get the link */ for (link = snode->edittree->links.first; link; link = link->next) |