From ae3073323e92a1773fb253bd1c5d6c92b826e1e0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Nov 2022 18:37:25 +1100 Subject: Cleanup: use bool instead of short for job stop & do_update arguments Since these values are only ever 0/1, use bool type. --- source/blender/editors/object/object_bake_api.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/object/object_bake_api.c') diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index d05badc8fee..260d65fc5dc 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -106,7 +106,7 @@ typedef struct BakeAPIRender { /* Progress Callbacks. */ float *progress; - short *do_update; + bool *do_update; /* Operator state. */ ReportList *reports; @@ -150,12 +150,12 @@ static int bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) * for exec() when there is no render job * NOTE: this won't check for the escape key being pressed, but doing so isn't thread-safe. */ -static int bake_break(void *UNUSED(rjv)) +static bool bake_break(void *UNUSED(rjv)) { if (G.is_break) { - return 1; + return true; } - return 0; + return false; } static void bake_update_image(ScrArea *area, Image *image) @@ -1854,7 +1854,7 @@ finally: return result; } -static void bake_startjob(void *bkv, short *UNUSED(stop), short *do_update, float *progress) +static void bake_startjob(void *bkv, bool *UNUSED(stop), bool *do_update, float *progress) { BakeAPIRender *bkr = (BakeAPIRender *)bkv; -- cgit v1.2.3 From 3852094b35ea659094ab30ffca9e2fe086b1a368 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Sat, 5 Nov 2022 22:40:17 +0100 Subject: Cleanup: Nodes: Use const arguments, avoid recursive iteration Use the node topology cache and avoid modifying the node tree in a non-threadsafe way to improve the predictability of using the helper function. Replaces the implementation from e0d40471364aafca967b6ebd52. --- source/blender/editors/object/object_bake_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/object/object_bake_api.c') diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 260d65fc5dc..d647578dc50 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -467,8 +467,8 @@ static bool bake_object_check(const Scene *scene, } for (int i = 0; i < ob->totcol; i++) { - bNodeTree *ntree = NULL; - bNode *node = NULL; + const bNodeTree *ntree = NULL; + const bNode *node = NULL; const int mat_nr = i + 1; Image *image; ED_object_get_active_image(ob, mat_nr, &image, NULL, &node, &ntree); -- cgit v1.2.3 From 0d945fe20e87ac7ada2d565f751146c2e8fa1ed6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 7 Nov 2022 15:43:20 +0100 Subject: Fix deprecation warnings about printf() on macOS The new Xcode 14.1 brings the new Apple Clang compiler which considers sprintf unsafe and geenrates deprecation warnings suggesting to sue snprintf instead. This only happens for C++ code by default, and C code can still use sprintf without any warning. This changes does the following: - Whenever is trivial replace sprintf() with BLI_snprintf. - For all other cases use the newly introduced BLI_sprintf which is a wrapper around sprintf() but without warning. There is a discouragement note in the BLI_sprintf comment to suggest use of BLI_snprintf when the size is known. Differential Revision: https://developer.blender.org/D16410 --- source/blender/editors/object/object_bake_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/object/object_bake_api.c') diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index d05badc8fee..b8e5c4e5522 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -893,7 +893,7 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, else { /* if everything else fails, use the material index */ char tmp[5]; - sprintf(tmp, "%d", i % 1000); + BLI_snprintf(tmp, sizeof(tmp), "%d", i % 1000); BLI_path_suffix(name, FILE_MAX, tmp, "_"); } } -- cgit v1.2.3