[Bf-blender-cvs] [f254f66587f] master: Cleanup: Editors/Space/Outliner, Clang-Tidy else-after-return fixes
Sybren A. Stüvel
noreply at git.blender.org
Fri Jul 3 17:43:27 CEST 2020
Commit: f254f66587f257b7de252644dd73574ad27a32af
Author: Sybren A. Stüvel
Date: Fri Jul 3 17:20:22 2020 +0200
Branches: master
https://developer.blender.org/rBf254f66587f257b7de252644dd73574ad27a32af
Cleanup: Editors/Space/Outliner, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/space_outliner` module.
No functional changes.
===================================================================
M source/blender/editors/space_outliner/outliner_collections.c
M source/blender/editors/space_outliner/outliner_dragdrop.c
M source/blender/editors/space_outliner/outliner_draw.c
M source/blender/editors/space_outliner/outliner_edit.c
M source/blender/editors/space_outliner/outliner_select.c
M source/blender/editors/space_outliner/outliner_tools.c
M source/blender/editors/space_outliner/outliner_tree.c
M source/blender/editors/space_outliner/outliner_utils.c
===================================================================
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 131491fcc40..4b012934ab7 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -70,7 +70,7 @@ bool outliner_is_collection_tree_element(const TreeElement *te)
TSE_VIEW_COLLECTION_BASE)) {
return true;
}
- else if (tselem->type == 0 && te->idcode == ID_GR) {
+ if (tselem->type == 0 && te->idcode == ID_GR) {
return true;
}
@@ -89,11 +89,11 @@ Collection *outliner_collection_from_tree_element(const TreeElement *te)
LayerCollection *lc = te->directdata;
return lc->collection;
}
- else if (ELEM(tselem->type, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE)) {
+ if (ELEM(tselem->type, TSE_SCENE_COLLECTION_BASE, TSE_VIEW_COLLECTION_BASE)) {
Scene *scene = (Scene *)tselem->id;
return scene->master_collection;
}
- else if (tselem->type == 0 && te->idcode == ID_GR) {
+ if (tselem->type == 0 && te->idcode == ID_GR) {
return (Collection *)tselem->id;
}
@@ -338,7 +338,7 @@ void outliner_collection_delete(
skip = true;
break;
}
- else if (parent->flag & COLLECTION_IS_MASTER) {
+ if (parent->flag & COLLECTION_IS_MASTER) {
Scene *parent_scene = BKE_collection_master_scene_search(bmain, parent);
if (ID_IS_LINKED(parent_scene)) {
skip = true;
@@ -1194,7 +1194,7 @@ static bool collection_flag_poll(bContext *C, bool clear, int flag)
if (clear && (collection->flag & flag)) {
return true;
}
- else if (!clear && !(collection->flag & flag)) {
+ if (!clear && !(collection->flag & flag)) {
return true;
}
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 70a628eead0..09d7f889bde 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -123,9 +123,7 @@ static ID *outliner_ID_drop_find(bContext *C, const wmEvent *event, short idcode
if (te && te->idcode == idcode && tselem->type == 0) {
return tselem->id;
}
- else {
- return NULL;
- }
+ return NULL;
}
/* Find tree element to drop into, with additional before and after reorder support. */
@@ -154,44 +152,35 @@ static TreeElement *outliner_drop_insert_find(bContext *C,
*r_insert_type = TE_INSERT_INTO;
return te_hovered;
}
- else {
- *r_insert_type = TE_INSERT_BEFORE;
- return te_hovered->subtree.first;
- }
+ *r_insert_type = TE_INSERT_BEFORE;
+ return te_hovered->subtree.first;
}
- else {
- *r_insert_type = TE_INSERT_AFTER;
- return te_hovered;
- }
- }
- else if (view_mval[1] > (te_hovered->ys + (3 * margin))) {
- *r_insert_type = TE_INSERT_BEFORE;
+ *r_insert_type = TE_INSERT_AFTER;
return te_hovered;
}
- else {
- *r_insert_type = TE_INSERT_INTO;
+ if (view_mval[1] > (te_hovered->ys + (3 * margin))) {
+ *r_insert_type = TE_INSERT_BEFORE;
return te_hovered;
}
+ *r_insert_type = TE_INSERT_INTO;
+ return te_hovered;
}
- else {
- /* Mouse doesn't hover any item (ignoring x-axis),
- * so it's either above list bounds or below. */
- TreeElement *first = soops->tree.first;
- TreeElement *last = soops->tree.last;
- if (view_mval[1] < last->ys) {
- *r_insert_type = TE_INSERT_AFTER;
- return last;
- }
- else if (view_mval[1] > (first->ys + UI_UNIT_Y)) {
- *r_insert_type = TE_INSERT_BEFORE;
- return first;
- }
- else {
- BLI_assert(0);
- return NULL;
- }
+ /* Mouse doesn't hover any item (ignoring x-axis),
+ * so it's either above list bounds or below. */
+ TreeElement *first = soops->tree.first;
+ TreeElement *last = soops->tree.last;
+
+ if (view_mval[1] < last->ys) {
+ *r_insert_type = TE_INSERT_AFTER;
+ return last;
}
+ if (view_mval[1] > (first->ys + UI_UNIT_Y)) {
+ *r_insert_type = TE_INSERT_BEFORE;
+ return first;
+ }
+ BLI_assert(0);
+ return NULL;
}
static Collection *outliner_collection_from_tree_element_and_parents(TreeElement *te,
@@ -270,9 +259,7 @@ static bool parent_drop_allowed(TreeElement *te, Object *potential_child)
}
return false;
}
- else {
- return true;
- }
+ return true;
}
static bool allow_parenting_without_modifier_key(SpaceOutliner *soops)
@@ -650,7 +637,7 @@ static Collection *collection_parent_from_ID(ID *id)
if (GS(id->name) == ID_SCE) {
return ((Scene *)id)->master_collection;
}
- else if (GS(id->name) == ID_GR) {
+ if (GS(id->name) == ID_GR) {
return (Collection *)id;
}
@@ -772,12 +759,10 @@ static bool collection_drop_poll(bContext *C,
}
return true;
}
- else {
- if (changed) {
- ED_region_tag_redraw_no_rebuild(region);
- }
- return false;
+ if (changed) {
+ ED_region_tag_redraw_no_rebuild(region);
}
+ return false;
}
static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 6f5f1294167..1a0f17425fa 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2816,13 +2816,11 @@ int tree_element_id_type_to_index(TreeElement *te)
if (id_index < INDEX_ID_OB) {
return id_index;
}
- else if (id_index == INDEX_ID_OB) {
+ if (id_index == INDEX_ID_OB) {
const Object *ob = (Object *)tselem->id;
return INDEX_ID_OB + ob->type;
}
- else {
- return id_index + OB_TYPE_MAX;
- }
+ return id_index + OB_TYPE_MAX;
}
typedef struct MergedIconRow {
@@ -3590,9 +3588,7 @@ static int outliner_width(SpaceOutliner *soops, int max_tree_width, float restri
if (soops->outlinevis == SO_DATA_API) {
return outliner_data_api_buttons_start_x(max_tree_width) + OL_RNA_COL_SIZEX + 10 * UI_DPI_FAC;
}
- else {
- return max_tree_width + restrict_column_width;
- }
+ return max_tree_width + restrict_column_width;
}
static void outliner_update_viewable_area(ARegion *region,
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index bee8b28e658..bead8ddcc42 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -500,14 +500,14 @@ static void id_delete(bContext *C, ReportList *reports, TreeElement *te, TreeSto
BKE_reportf(reports, RPT_WARNING, "Cannot delete indirectly linked id '%s'", id->name);
return;
}
- else if (BKE_library_ID_is_indirectly_used(bmain, id) && ID_REAL_USERS(id) <= 1) {
+ if (BKE_library_ID_is_indirectly_used(bmain, id) && ID_REAL_USERS(id) <= 1) {
BKE_reportf(reports,
RPT_WARNING,
"Cannot delete id '%s', indirectly used data-blocks need at least one user",
id->name);
return;
}
- else if (te->idcode == ID_WS) {
+ if (te->idcode == ID_WS) {
BKE_workspace_id_tag_all_visible(bmain, LIB_TAG_DOIT);
if (id->tag & LIB_TAG_DOIT) {
BKE_reportf(
@@ -947,12 +947,10 @@ static int outliner_lib_relocate_invoke_do(
((Library *)tselem->id)->filepath_abs);
return OPERATOR_CANCELLED;
}
- else {
- wmOperatorType *ot = WM_operatortype_find(
- reload ? "WM_OT_lib_reload" : "WM_OT_lib_relocate", false);
- return lib_relocate(C, te, tselem, ot, reload);
- }
+ wmOperatorType *ot = WM_operatortype_find(reload ? "WM_OT_lib_reload" : "WM_OT_lib_relocate",
+ false);
+ return lib_relocate(C, te, tselem, ot, reload);
}
}
else {
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 8a408a41897..5f025f08130 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -520,9 +520,7 @@ static eOLDrawState tree_element_active_camera(bContext *C,
return OL_DRAWSEL_NONE;
}
- else {
- return scene->camera == ob;
- }
+ return scene->camera == ob;
}
static eOLDrawState tree_element_active_world(bContext *C,
@@ -1001,9 +999,7 @@ static eOLDrawState tree_element_active_keymap_item(bContext *UNUSED(C),
}
return OL_DRAWSEL_NORMAL;
}
- else {
- kmi->flag ^= KMI_INACTIVE;
- }
+ kmi->flag ^= KMI_INACTIVE;
return OL_DRAWSEL_NONE;
}
@@ -1620,9 +1616,7 @@ static TreeElement *outliner_element_find_successor_in_parents(TreeElement *te)
te = successor->parent->next;
break;
}
- else {
- successor = successor->parent;
- }
+ successor = successor->parent;
}
return te;
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index c0632de1cd7..0aa82783b7a 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -699,8 +699,8 @@ static void outliner_object_delete_fn(bContext *C, ReportList *reports, Scene *s
reports, RPT_WARNING, "Cannot delete indirectly linked object '%s'", ob->id.name + 2);
return;
}
- else if (BKE_library_ID_is_indirectly_used(bmain, ob) && ID_REAL_USERS(ob) <= 1 &&
- ID_EXTRA_USERS(ob) == 0) {
+ if (BKE_library_ID_is_indirectly_used(bmain, ob) && ID_REAL_USERS(ob) <= 1 &&
+ ID_EXTRA_USERS(ob) == 0) {
BKE_reportf(reports,
RPT_WARNING,
"Cannot delete object '%s' from scene '%s', indirectly used objects need at "
@@ -1202,8 +1202,8 @@ static Base *outline_batch_delete_hierarchy(
base->object->id.name + 2);
return base_next;
}
- else if (BKE_libra
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list