int id_unlink(ID *id, int test) { Main *mainlib = G.main; ListBase *lb; switch (GS(id->name)) { case ID_TXT: if (test) return 1; BKE_text_unlink(mainlib, (Text *)id); break; case ID_GR: if (test) return 1; BKE_group_unlink((Group *)id); break; case ID_OB: if (test) return 1; BKE_object_unlink((Object *)id); break; } if (id->us == 0) { if (test) return 1; lb = which_libbase(mainlib, GS(id->name)); BKE_libblock_free(lb, id); return 1; } return 0; }
bool id_unlink(ID *id, int test) { Main *mainlib = G.main; short type = GS(id->name); switch (type) { case ID_TXT: if (test) return true; BKE_text_unlink(mainlib, (Text *)id); break; case ID_GR: if (test) return true; BKE_group_unlink((Group *)id); break; case ID_OB: if (test) return true; BKE_object_unlink((Object *)id); break; } if (id->us == 0) { if (test) return true; BKE_libblock_free(mainlib, id); return true; } return false; }
void BKE_libblock_free_us(ListBase *lb, void *idv) /* test users */ { ID *id = idv; id->us--; if (id->us < 0) { if (id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us); else printf("ERROR block %s users %d\n", id->name, id->us); } if (id->us == 0) { if (GS(id->name) == ID_OB) BKE_object_unlink((Object *)id); BKE_libblock_free(lb, id); } }