BMain: Add utils to check if a Main is empty or not.
Mostly intended for debug code (asserts).
This commit is contained in:
parent
0194e54fd3
commit
b7dc0346aa
|
@ -201,6 +201,8 @@ typedef struct Main {
|
|||
struct Main *BKE_main_new(void);
|
||||
void BKE_main_free(struct Main *mainvar);
|
||||
|
||||
bool BKE_main_is_empty(struct Main *bmain);
|
||||
|
||||
void BKE_main_lock(struct Main *bmain);
|
||||
void BKE_main_unlock(struct Main *bmain);
|
||||
|
||||
|
|
|
@ -205,6 +205,17 @@ void BKE_main_free(Main *mainvar)
|
|||
MEM_freeN(mainvar);
|
||||
}
|
||||
|
||||
/* Check whether given `bmain` is empty or contains some IDs. */
|
||||
bool BKE_main_is_empty(struct Main *bmain)
|
||||
{
|
||||
ID *id_iter;
|
||||
FOREACH_MAIN_ID_BEGIN (bmain, id_iter) {
|
||||
return false;
|
||||
}
|
||||
FOREACH_MAIN_ID_END;
|
||||
return true;
|
||||
}
|
||||
|
||||
void BKE_main_lock(struct Main *bmain)
|
||||
{
|
||||
BLI_spin_lock((SpinLock *)bmain->lock);
|
||||
|
|
Loading…
Reference in New Issue