From 01b94c5d8a99c20ab86ee1ea9fd9d0f4aab64dab Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 1 Dec 2020 10:45:02 +0100 Subject: Cleanup: De-duplicate object mullptr checks Makes it more clear whether object is allowed or not allowed to be NULL. Also, avoids possible access to the different object mode enumerator. Should be no functional changes. --- source/blender/editors/space_info/info_stats.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 71144fa11d0..890bb8a64bc 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -351,9 +351,13 @@ static void stats_object_pose(Object *ob, SceneStats *stats) } } -static bool stats_is_object_dynamic_topology_sculpt(Object *ob, const eObjectMode object_mode) +static bool stats_is_object_dynamic_topology_sculpt(Object *ob) { - return (ob && (object_mode & OB_MODE_SCULPT) && ob->sculpt && ob->sculpt->bm); + if (ob == NULL) { + return false; + } + const eObjectMode object_mode = ob->mode; + return ((object_mode & OB_MODE_SCULPT) && ob->sculpt && ob->sculpt->bm); } static void stats_object_sculpt(Object *ob, SceneStats *stats) @@ -405,7 +409,7 @@ static void stats_update(Depsgraph *depsgraph, ViewLayer *view_layer) /* Pose Mode */ stats_object_pose(ob, &stats); } - else if (ob && stats_is_object_dynamic_topology_sculpt(ob, ob->mode)) { + else if (stats_is_object_dynamic_topology_sculpt(ob)) { /* Dynamic topology. Do not count all vertices, dynamic topology stats are initialized later as * part of sculpt stats. */ } @@ -555,7 +559,7 @@ static void get_stats_string( stats_fmt->totgpstroke, stats_fmt->totgppoint); } - else if (stats_is_object_dynamic_topology_sculpt(ob, object_mode)) { + else if (stats_is_object_dynamic_topology_sculpt(ob)) { *ofs += BLI_snprintf(info + *ofs, len - *ofs, TIP_("Verts:%s | Tris:%s"), @@ -756,7 +760,7 @@ void ED_info_draw_stats( stats_row(col1, labels[POINTS], col2, stats_fmt.totgppoint, NULL, y, height); } else if (ob && (object_mode & OB_MODE_SCULPT)) { - if (stats_is_object_dynamic_topology_sculpt(ob, object_mode)) { + if (stats_is_object_dynamic_topology_sculpt(ob)) { stats_row(col1, labels[VERTS], col2, stats_fmt.totvertsculpt, NULL, y, height); stats_row(col1, labels[TRIS], col2, stats_fmt.tottri, NULL, y, height); } -- cgit v1.2.3