diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-22 12:37:08 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-06-22 12:37:08 +0300 |
commit | 1870a1adc75dece1e9eac3aa632da6e903780c86 (patch) | |
tree | 2cf12f98d0540b3901081bbd3184cb4c8b376bbf /source/blender/blenkernel | |
parent | a0dce6810d8bafd0205e6847fea3febfc08a7bd7 (diff) |
BKE_library: Add func to check an ID is actually in G_MAIN database.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_library.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 935e90d7ed0..c2b971a91cd 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -200,6 +200,8 @@ void BKE_library_make_local( void BKE_id_tag_set_atomic(struct ID *id, int tag); void BKE_id_tag_clear_atomic(struct ID *id, int tag); +bool BKE_id_is_in_gobal_main(struct ID *id); + /* use when "" is given to new_id() */ #define ID_FALLBACK_NAME N_("Untitled") diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 37d7004192d..444e155f5ac 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -2414,3 +2414,10 @@ void BKE_id_tag_clear_atomic(ID *id, int tag) { atomic_fetch_and_and_int32(&id->tag, ~tag); } + +/** Check that given ID pointer actually is in G_MAIN. + * Main intended use is for debug asserts in places we cannot easily get rid of G_Main... */ +bool BKE_id_is_in_gobal_main(ID *id) { + return (BLI_findindex(which_libbase(G_MAIN, GS(id->name)), id) != -1); +} + |