[Bf-blender-cvs] [1870a1adc75] master: BKE_library: Add func to check an ID is actually in G_MAIN database.

Bastien Montagne noreply at git.blender.org
Fri Jun 22 12:37:05 CEST 2018


Commit: 1870a1adc75dece1e9eac3aa632da6e903780c86
Author: Bastien Montagne
Date:   Fri Jun 22 11:37:08 2018 +0200
Branches: master
https://developer.blender.org/rB1870a1adc75dece1e9eac3aa632da6e903780c86

BKE_library: Add func to check an ID is actually in G_MAIN database.

===================================================================

M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/intern/library.c

===================================================================

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);
+}
+



More information about the Bf-blender-cvs mailing list