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

This commit is contained in:
Bastien Montagne 2018-06-22 11:37:08 +02:00
parent a0dce6810d
commit 1870a1adc7
2 changed files with 9 additions and 0 deletions

View File

@ -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")

View File

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