Blender Git Loki

Git Commits -> Revision 280dac3

Revision 280dac3 by Julian Eisel (master)
July 12, 2021, 09:46 (GMT)
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

Commit Details:

Full Hash: 280dac323cc83dba9d95646c8cd4bcdbb1cb51c2
Parent Commit: c4f9bfc
Lines Changed: +15, -0

2 Modified Paths:

/source/blender/blenlib/BLI_assert.h (+10, -0) (Diff)
/source/blender/blenlib/intern/BLI_assert.c (+5, -0) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021