[Bf-blender-cvs] [9dce2c9d143] master: Cleanup: Editors/GPencil, Clang-Tidy else-after-return fixes
Sybren A. Stüvel
noreply at git.blender.org
Fri Jul 3 14:49:23 CEST 2020
Commit: 9dce2c9d1432d2798854b909e6262fbfb94ce3c7
Author: Sybren A. Stüvel
Date: Fri Jul 3 14:38:26 2020 +0200
Branches: master
https://developer.blender.org/rB9dce2c9d1432d2798854b909e6262fbfb94ce3c7
Cleanup: Editors/GPencil, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/editors/gpencil` module.
No functional changes.
===================================================================
M source/blender/editors/gpencil/annotate_paint.c
M source/blender/editors/gpencil/gpencil_data.c
M source/blender/editors/gpencil/gpencil_edit.c
M source/blender/editors/gpencil/gpencil_fill.c
M source/blender/editors/gpencil/gpencil_interpolate.c
M source/blender/editors/gpencil/gpencil_merge.c
M source/blender/editors/gpencil/gpencil_ops.c
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/gpencil/gpencil_primitive.c
M source/blender/editors/gpencil/gpencil_sculpt_paint.c
M source/blender/editors/gpencil/gpencil_select.c
M source/blender/editors/gpencil/gpencil_utils.c
===================================================================
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 9d80a75b959..6f700f6c4b8 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -233,9 +233,7 @@ static bool annotation_draw_poll(bContext *C)
if (ED_gpencil_session_active() == 0) {
return true;
}
- else {
- CTX_wm_operator_poll_msg_set(C, "Annotation operator is already active");
- }
+ CTX_wm_operator_poll_msg_set(C, "Annotation operator is already active");
}
else {
CTX_wm_operator_poll_msg_set(C, "Failed to find Annotation data to draw into");
@@ -281,40 +279,39 @@ static bool annotation_stroke_filtermval(tGPsdata *p, const float mval[2], float
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
if (p->gpd->runtime.sbuffer_used == 0) {
return true;
-
- /* check if mouse moved at least certain distance on both axes (best case)
- * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
- */
}
+
+ /* check if mouse moved at least certain distance on both axes (best case)
+ * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand
+ */
+
/* If lazy mouse, check minimum distance. */
- else if (p->flags & GP_PAINTFLAG_USE_STABILIZER_TEMP) {
+ if (p->flags & GP_PAINTFLAG_USE_STABILIZER_TEMP) {
if ((dx * dx + dy * dy) > (p->stabilizer_radius * p->stabilizer_radius)) {
return true;
}
- else {
- /* If the mouse is moving within the radius of the last move,
- * don't update the mouse position. This allows sharp turns. */
- copy_v2_v2(p->mval, p->mvalo);
- return false;
- }
- }
- else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
- return true;
- /* Check if the distance since the last point is significant enough:
- * - Prevents points being added too densely
- * - Distance here doesn't use sqrt to prevent slowness.
- * We should still be safe from overflows though.
- */
+ /* If the mouse is moving within the radius of the last move,
+ * don't update the mouse position. This allows sharp turns. */
+ copy_v2_v2(p->mval, p->mvalo);
+ return false;
}
- else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
- return true;
- /* mouse 'didn't move' */
+ if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) {
+ return true;
}
- else {
- return false;
+
+ /* Check if the distance since the last point is significant enough:
+ * - Prevents points being added too densely
+ * - Distance here doesn't use sqrt to prevent slowness.
+ * We should still be safe from overflows though.
+ */
+ if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) {
+ return true;
}
+
+ /* mouse 'didn't move' */
+ return false;
}
/* convert screen-coordinates to buffer-coordinates */
@@ -594,7 +591,8 @@ static short annotation_stroke_addpoint(tGPsdata *p,
/* can keep carrying on this way :) */
return GP_STROKEADD_NORMAL;
}
- else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
+
+ if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
/* check if still room in buffer or add more */
gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure(
gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, false);
@@ -624,7 +622,8 @@ static short annotation_stroke_addpoint(tGPsdata *p,
return GP_STROKEADD_NORMAL;
}
- else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
+
+ if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
/* get pointer to destination point */
pt = (tGPspoint *)gpd->runtime.sbuffer;
@@ -1083,9 +1082,7 @@ static float view3d_point_depth(const RegionView3D *rv3d, const float co[3])
if (rv3d->is_persp) {
return ED_view3d_calc_zfac(rv3d, co, NULL);
}
- else {
- return -dot_v3v3(rv3d->viewinv[2], co);
- }
+ return -dot_v3v3(rv3d->viewinv[2], co);
}
/* only erase stroke points that are visible (3d view) */
@@ -1412,17 +1409,16 @@ static bool annotation_session_initdata(bContext *C, tGPsdata *p)
}
return 0;
}
- else {
- /* if no existing GPencil block exists, add one */
- if (*gpd_ptr == NULL) {
- bGPdata *gpd = BKE_gpencil_data_addnew(bmain, "Annotations");
- *gpd_ptr = gpd;
- /* mark datablock as being used for annotations */
- gpd->flag |= GP_DATA_ANNOTATIONS;
- }
- p->gpd = *gpd_ptr;
+ /* if no existing GPencil block exists, add one */
+ if (*gpd_ptr == NULL) {
+ bGPdata *gpd = BKE_gpencil_data_addnew(bmain, "Annotations");
+ *gpd_ptr = gpd;
+
+ /* mark datablock as being used for annotations */
+ gpd->flag |= GP_DATA_ANNOTATIONS;
}
+ p->gpd = *gpd_ptr;
if (ED_gpencil_session_active() == 0) {
/* initialize undo stack,
@@ -1570,9 +1566,8 @@ static void annotation_paint_initstroke(tGPsdata *p,
}
return;
}
- else {
- p->gpf->flag |= GP_FRAME_PAINT;
- }
+
+ p->gpf->flag |= GP_FRAME_PAINT;
}
/* set 'eraser' for this stroke if using eraser */
@@ -2200,9 +2195,8 @@ static int annotation_draw_exec(bContext *C, wmOperator *op)
/* printf("\tGP - no valid data\n"); */
return OPERATOR_CANCELLED;
}
- else {
- p = op->customdata;
- }
+
+ p = op->customdata;
/* printf("\tGP - Start redrawing stroke\n"); */
@@ -2285,9 +2279,8 @@ static int annotation_draw_invoke(bContext *C, wmOperator *op, const wmEvent *ev
}
return OPERATOR_CANCELLED;
}
- else {
- p = op->customdata;
- }
+
+ p = op->customdata;
/* if empty erase capture and finish */
if (p->status == GP_STATUS_CAPTURE) {
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 44b866d81d7..96b0296a7de 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -176,13 +176,11 @@ static int gpencil_data_unlink_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
return OPERATOR_CANCELLED;
}
- else {
- /* just unlink datablock now, decreasing its user count */
- bGPdata *gpd = (*gpd_ptr);
+ /* just unlink datablock now, decreasing its user count */
+ bGPdata *gpd = (*gpd_ptr);
- id_us_min(&gpd->id);
- *gpd_ptr = NULL;
- }
+ id_us_min(&gpd->id);
+ *gpd_ptr = NULL;
/* notifiers */
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
@@ -1125,9 +1123,7 @@ static int gpencil_isolate_layer_exec(bContext *C, wmOperator *op)
if (gpl == layer) {
continue;
}
- else {
- gpl->flag |= flags;
- }
+ gpl->flag |= flags;
}
}
else {
@@ -2913,9 +2909,7 @@ static int gpencil_material_isolate_exec(bContext *C, wmOperator *op)
if (gp_style == active_color) {
continue;
}
- else {
- gp_style->flag |= flags;
- }
+ gp_style->flag |= flags;
DEG_id_tag_update(&ma->id, ID_RECALC_COPY_ON_WRITE);
}
}
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 78e2812fdef..f8010edfcdd 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1490,13 +1490,15 @@ static int gpencil_strokes_paste_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Operator not supported in multiframe edition");
return OPERATOR_CANCELLED;
}
- else if (BLI_listbase_is_empty(&gpencil_strokes_copypastebuf)) {
+
+ if (BLI_listbase_is_empty(&gpencil_strokes_copypastebuf)) {
BKE_report(op->reports,
RPT_ERROR,
"No strokes to paste, select and copy some points before trying again");
return OPERATOR_CANCELLED;
}
- else if (gpl == NULL) {
+
+ if (gpl == NULL) {
/* no active layer - let's just create one */
gpl = BKE_gpencil_layer_addnew(gpd, DATA_("GP_Layer"), true);
}
@@ -1955,10 +1957,8 @@ static int gpencil_actframe_delete_all_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
- else {
- BKE_report(op->reports, RPT_ERROR, "No active frame(s) to delete");
- return OPERATOR_CANCELLED;
- }
+ BKE_report(op->reports, RPT_ERROR, "No active frame(s) to delete");
+ return OPERATOR_CANCELLED;
}
void GPENCIL_OT_active_frames_delete_all(wmOperatorType *ot)
@@ -2050,9 +2050,7 @@ static int gpencil_delete_selected_strokes(bContext *C)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* ----------------------------------- */
@@ -2268,9 +2266,7 @@ static int gpencil_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* ----------------------------------- */
@@ -2583,9 +2579,7 @@ static int gpencil_delete_selected_points(bContext *C)
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
- else {
- return OPERATOR_CANCELLED;
- }
+ return OPERATOR_CANCELLED;
}
/* simple wrapper to external call */
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 35bd44b88f9..8c901da100d 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -1199,15 +1199,12 @@ static bool gpencil_fill_poll(bContext *C)
return true;
}
- else {
- CTX_wm_operator_poll_msg_set(C, "Active region not valid for filling operator");
- return false;
- }
- }
- else {
- CTX_wm_operator_poll_msg_set(C, "Active region not set");
+ CTX_wm_operator_poll_msg_set(C, "Active region
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list