Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-07-12 12:46:24 +0300
committerJulian Eisel <julian@blender.org>2021-07-12 12:46:24 +0300
commit280dac323cc83dba9d95646c8cd4bcdbb1cb51c2 (patch)
tree3a0c2a51654fc7a868f85c31f1b8d0bead0f5120 /source/blender/blenlib/intern/BLI_assert.c
parentc4f9bfcf5e7ddfaeacdea6dc9b01868edf74182f (diff)
Blenlib: Add BLI_assert_msg() for printing an extra string if the assert fails
It always bothered me that we'd do the `BLI_assert(... || !"message")` trick to print a message alongside the assert, while it should be trivial to have a way to pass an extra string as additional argument. This adds `BLI_assert_msg()` with a second argument for a message. E.g.: ``` BLI_assert_msg( params->rename_id == NULL, "File rename handling should immediately clear rename_id when done, because otherwise it will keep taking precedence over renamefile."); ``` On failure this will print like this: ``` 0 Blender 0x00000001140647a3 BLI_system_backtrace + 291 [...] 13 Blender 0x00000001092647a6 main + 3814 14 libdyld.dylib 0x00007fff203d8f5d start + 1 BLI_assert failed: source/blender/editors/space_file/file_ops.c:2352, file_directory_new_exec(), at 'params->rename_id == ((void*)0)' File rename handling should immediately clear rename_id when done, because otherwise it will keep taking precedence over renamefile. ``` Reviewed by: Sybren Stüvel, Jacques Lucke, Sergey Sharybin, Campbell Barton Differential Revision: https://developer.blender.org/D11827
Diffstat (limited to 'source/blender/blenlib/intern/BLI_assert.c')
-rw-r--r--source/blender/blenlib/intern/BLI_assert.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_assert.c b/source/blender/blenlib/intern/BLI_assert.c
index 887f583242f..cebc6f8957f 100644
--- a/source/blender/blenlib/intern/BLI_assert.c
+++ b/source/blender/blenlib/intern/BLI_assert.c
@@ -31,6 +31,11 @@ void _BLI_assert_print_pos(const char *file, const int line, const char *functio
fprintf(stderr, "BLI_assert failed: %s:%d, %s(), at \'%s\'\n", file, line, function, id);
}
+void _BLI_assert_print_extra(const char *str)
+{
+ fprintf(stderr, " %s\n", str);
+}
+
void _BLI_assert_unreachable_print(const char *file, const int line, const char *function)
{
fprintf(stderr, "Code marked as unreachable has been executed. Please report this as a bug.\n");