diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-02-07 23:07:10 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-02-07 23:24:05 +0400 |
commit | b3afbcab8ff2330c1473647be330a3ffe9b11885 (patch) | |
tree | e86b9c7d9676e63b8da92da79889dee13b8be186 /source/blender/editors/space_node | |
parent | 1c24d954f4ac63f22b703756b6664a4ad1b363d4 (diff) |
ListBase API: add utility api funcs for clearing and checking empty
Diffstat (limited to 'source/blender/editors/space_node')
5 files changed, 9 insertions, 8 deletions
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index a1b1b453ee0..428495542c2 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -232,8 +232,9 @@ static int add_reroute_exec(bContext *C, wmOperator *op) node_deselect_all(snode); /* Find cut links and sort them by sockets */ - output_links.first = output_links.last = NULL; - input_links.first = input_links.last = NULL; + BLI_listbase_clear(&output_links); + BLI_listbase_clear(&input_links); + for (link = ntree->links.first; link; link = link->next) { if (nodeLinkIsHidden(link)) continue; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 9f76a9f1eb5..114b45ed174 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2002,7 +2002,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) clipboard_nodes_lb = BKE_node_clipboard_get_nodes(); clipboard_links_lb = BKE_node_clipboard_get_links(); - if (clipboard_nodes_lb->first == NULL) { + if (BLI_listbase_is_empty(clipboard_nodes_lb)) { BKE_report(op->reports, RPT_ERROR, "Clipboard is empty"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 31a9ec70660..3e1e605682f 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -274,7 +274,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode) bNodeSocket *sock; /* context check */ - if (tonode == NULL || tonode->outputs.first == NULL) + if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs)) return OPERATOR_CANCELLED; if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) return OPERATOR_CANCELLED; @@ -1209,7 +1209,7 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, return false; /* correct node */ - if (select->inputs.first == NULL || select->outputs.first == NULL) + if (BLI_listbase_is_empty(&select->inputs) || BLI_listbase_is_empty(&select->outputs)) return false; /* test node for links */ diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index ac0010b1d55..13a702e09c4 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -387,7 +387,7 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR]) else BLI_strncpy(node_name, node->typeinfo->ui_name, UI_MAX_NAME_STR); - if (node->inputs.first == NULL && + if (BLI_listbase_is_empty(&node->inputs) && node->outputs.first != node->outputs.last) { BLI_snprintf(name, UI_MAX_NAME_STR, "%s | %s", IFACE_(node_name), IFACE_(sock->link->fromsock->name)); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 2fe63c4b895..b8bb196b9c6 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -70,7 +70,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from) path_next = path->next; MEM_freeN(path); } - snode->treepath.first = snode->treepath.last = NULL; + BLI_listbase_clear(&snode->treepath); if (ntree) { path = MEM_callocN(sizeof(bNodeTreePath), "node tree path"); @@ -558,7 +558,7 @@ static SpaceLink *node_duplicate(SpaceLink *sl) BLI_duplicatelist(&snoden->treepath, &snode->treepath); /* clear or remove stuff from old */ - snoden->linkdrag.first = snoden->linkdrag.last = NULL; + BLI_listbase_clear(&snoden->linkdrag); /* Note: no need to set node tree user counts, * the editor only keeps at least 1 (id_us_ensure_real), |