Cleanup: Editors/Space/Node, Clang-Tidy else-after-return fixes

This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/space_node` module.

No functional changes.
This commit is contained in:
2020-07-03 17:20:08 +02:00
parent bf532b1106
commit 3aa53b361d
9 changed files with 44 additions and 72 deletions

View File

@@ -284,23 +284,21 @@ static int node_resize_area_default(bNode *node, int x, int y)
if (BLI_rctf_isect_pt(&totr, x, y)) {
return NODE_RESIZE_RIGHT;
}
else {
return 0;
}
}
else {
const float size = NODE_RESIZE_MARGIN;
rctf totr = node->totr;
int dir = 0;
if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_RIGHT;
}
if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_LEFT;
}
return dir;
return 0;
}
const float size = NODE_RESIZE_MARGIN;
rctf totr = node->totr;
int dir = 0;
if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_RIGHT;
}
if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) {
dir |= NODE_RESIZE_LEFT;
}
return dir;
}
/* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
@@ -3833,7 +3831,7 @@ static bool node_link_bezier_handles(View2D *v2d,
if (v2d && min_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) {
return 0; /* clipped */
}
else if (v2d && max_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) {
if (v2d && max_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) {
return 0; /* clipped */
}

View File

@@ -382,9 +382,7 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even
RNA_struct_property_is_set(op->ptr, "name")) {
return node_add_file_exec(C, op);
}
else {
return WM_operator_filesel(C, op, event);
}
return WM_operator_filesel(C, op, event);
}
void NODE_OT_add_file(wmOperatorType *ot)

View File

@@ -97,9 +97,7 @@ static bNodeTree *node_tree_from_ID(ID *id)
if (GS(id->name) == ID_NT) {
return (bNodeTree *)id;
}
else {
return ntreeFromID(id);
}
return ntreeFromID(id);
}
return NULL;
@@ -217,7 +215,7 @@ static bool compare_nodes(const bNode *a, const bNode *b)
if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND)) {
return 0;
}
else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) {
if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) {
return 1;
}
@@ -225,7 +223,7 @@ static bool compare_nodes(const bNode *a, const bNode *b)
if (!b_active && a_active) {
return 1;
}
else if (!b_select && (a_active || a_select)) {
if (!b_select && (a_active || a_select)) {
return 1;
}
@@ -1558,15 +1556,13 @@ int node_get_resize_cursor(int directions)
if (directions == 0) {
return WM_CURSOR_DEFAULT;
}
else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) {
if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) {
return WM_CURSOR_Y_MOVE;
}
else if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) {
if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) {
return WM_CURSOR_X_MOVE;
}
else {
return WM_CURSOR_EDIT;
}
return WM_CURSOR_EDIT;
}
void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2])

View File

@@ -107,13 +107,13 @@ static const char *group_node_idname(bContext *C)
if (ED_node_is_shader(snode)) {
return "ShaderNodeGroup";
}
else if (ED_node_is_compositor(snode)) {
if (ED_node_is_compositor(snode)) {
return "CompositorNodeGroup";
}
else if (ED_node_is_texture(snode)) {
if (ED_node_is_texture(snode)) {
return "TextureNodeGroup";
}
else if (ED_node_is_simulation(snode)) {
if (ED_node_is_simulation(snode)) {
return "SimulationNodeGroup";
}
@@ -128,9 +128,7 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname)
if (node && STREQ(node->idname, node_idname)) {
return node;
}
else {
return NULL;
}
return NULL;
}
/* ***************** Edit Group operator ************* */

View File

@@ -76,10 +76,9 @@ static bool ntree_check_nodes_connected_dfs(bNodeTree *ntree, bNode *from, bNode
if (link->tonode == to) {
return true;
}
else {
if (ntree_check_nodes_connected_dfs(ntree, link->tonode, to)) {
return true;
}
if (ntree_check_nodes_connected_dfs(ntree, link->tonode, to)) {
return true;
}
}
}
@@ -191,9 +190,7 @@ static int sort_nodes_locx(const void *a, const void *b)
if (node1->locx > node2->locx) {
return 1;
}
else {
return 0;
}
return 0;
}
static bool socket_is_available(bNodeTree *UNUSED(ntree), bNodeSocket *sock, const bool allow_used)
@@ -921,9 +918,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
else {
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
}
static void node_link_cancel(bContext *C, wmOperator *op)
@@ -1078,9 +1073,8 @@ static int cut_links_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
else {
return OPERATOR_CANCELLED;
}
return OPERATOR_CANCELLED;
}
return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH;
@@ -1473,9 +1467,7 @@ static bool ed_node_link_conditions(ScrArea *area,
if (select) {
break;
}
else {
select = node;
}
select = node;
}
}
/* only one selected */

View File

@@ -1097,9 +1097,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
if (node->type == active->type) {
break;
}
else {
node = NULL;
}
node = NULL;
}
if (node) {
active = node;

View File

@@ -71,9 +71,7 @@ static bool node_link_item_compare(bNode *node, NodeLinkItem *item)
if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
return (node->id == (ID *)item->ngroup);
}
else {
return true;
}
return true;
}
static void node_link_item_apply(Main *bmain, bNode *node, NodeLinkItem *item)

View File

@@ -133,9 +133,7 @@ static int node_view_all_exec(bContext *C, wmOperator *op)
if (space_node_view_flag(C, snode, region, 0, smooth_viewtx)) {
return OPERATOR_FINISHED;
}
else {
return OPERATOR_CANCELLED;
}
return OPERATOR_CANCELLED;
}
void NODE_OT_view_all(wmOperatorType *ot)
@@ -162,9 +160,7 @@ static int node_view_selected_exec(bContext *C, wmOperator *op)
if (space_node_view_flag(C, snode, region, NODE_SELECT, smooth_viewtx)) {
return OPERATOR_FINISHED;
}
else {
return OPERATOR_CANCELLED;
}
return OPERATOR_CANCELLED;
}
void NODE_OT_view_selected(wmOperatorType *ot)

View File

@@ -641,9 +641,7 @@ static bool node_ima_drop_poll(bContext *UNUSED(C),
/* rule might not work? */
return (ELEM(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_MOVIE));
}
else {
return WM_drag_ID(drag, ID_IM) != NULL;
}
return WM_drag_ID(drag, ID_IM) != NULL;
}
static bool node_mask_drop_poll(bContext *UNUSED(C),
@@ -787,7 +785,7 @@ static int node_context(const bContext *C, const char *member, bContextDataResul
CTX_data_dir_set(result, node_context_dir);
return 1;
}
else if (CTX_data_equals(member, "selected_nodes")) {
if (CTX_data_equals(member, "selected_nodes")) {
bNode *node;
if (snode->edittree) {
@@ -800,7 +798,7 @@ static int node_context(const bContext *C, const char *member, bContextDataResul
CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
return 1;
}
else if (CTX_data_equals(member, "active_node")) {
if (CTX_data_equals(member, "active_node")) {
if (snode->edittree) {
bNode *node = nodeGetActive(snode->edittree);
CTX_data_pointer_set(result, &snode->edittree->id, &RNA_Node, node);
@@ -809,7 +807,7 @@ static int node_context(const bContext *C, const char *member, bContextDataResul
CTX_data_type_set(result, CTX_DATA_TYPE_POINTER);
return 1;
}
else if (CTX_data_equals(member, "node_previews")) {
if (CTX_data_equals(member, "node_previews")) {
if (snode->nodetree) {
CTX_data_pointer_set(
result, &snode->nodetree->id, &RNA_NodeInstanceHash, snode->nodetree->previews);
@@ -818,19 +816,19 @@ static int node_context(const bContext *C, const char *member, bContextDataResul
CTX_data_type_set(result, CTX_DATA_TYPE_POINTER);
return 1;
}
else if (CTX_data_equals(member, "material")) {
if (CTX_data_equals(member, "material")) {
if (snode->id && GS(snode->id->name) == ID_MA) {
CTX_data_id_pointer_set(result, snode->id);
}
return 1;
}
else if (CTX_data_equals(member, "light")) {
if (CTX_data_equals(member, "light")) {
if (snode->id && GS(snode->id->name) == ID_LA) {
CTX_data_id_pointer_set(result, snode->id);
}
return 1;
}
else if (CTX_data_equals(member, "world")) {
if (CTX_data_equals(member, "world")) {
if (snode->id && GS(snode->id->name) == ID_WO) {
CTX_data_id_pointer_set(result, snode->id);
}