Tweak new BKE_id_is_in_global_main to accept NULL pointer (and consider them as valid).

This commit is contained in:
Bastien Montagne
2018-06-22 12:26:45 +02:00
parent cbf5c738d6
commit 101fd7ec06

View File

@@ -2418,6 +2418,7 @@ void BKE_id_tag_clear_atomic(ID *id, int 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);
/* We do not want to fail when id is NULL here, even though this is a bit strange behavior... */
return (id == NULL || BLI_findindex(which_libbase(G_MAIN, GS(id->name)), id) != -1);
}