Library API: pass Main struct to unlink functions
This commit is contained in:
parent
56bcda8bc6
commit
7a9693fa8b
|
@ -41,7 +41,7 @@ struct Object;
|
|||
struct Scene;
|
||||
|
||||
void BKE_group_free(struct Group *group);
|
||||
void BKE_group_unlink(struct Group *group);
|
||||
void BKE_group_unlink(struct Main *bmain, struct Group *group);
|
||||
struct Group *BKE_group_add(struct Main *bmain, const char *name);
|
||||
struct Group *BKE_group_copy(struct Group *group);
|
||||
bool BKE_group_object_add(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base);
|
||||
|
|
|
@ -79,7 +79,7 @@ void BKE_object_free_modifiers(struct Object *ob);
|
|||
void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob);
|
||||
void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target);
|
||||
|
||||
void BKE_object_unlink(struct Object *ob);
|
||||
void BKE_object_unlink(struct Main *bmain, struct Object *ob);
|
||||
bool BKE_object_exists_check(struct Object *obtest);
|
||||
bool BKE_object_is_in_editmode(struct Object *ob);
|
||||
bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
|
||||
|
|
|
@ -73,9 +73,8 @@ void BKE_group_free(Group *group)
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_group_unlink(Group *group)
|
||||
void BKE_group_unlink(Main *bmain, Group *group)
|
||||
{
|
||||
Main *bmain = G.main;
|
||||
Material *ma;
|
||||
Object *ob;
|
||||
Scene *sce;
|
||||
|
|
|
@ -406,11 +406,11 @@ bool id_unlink(ID *id, int test)
|
|||
break;
|
||||
case ID_GR:
|
||||
if (test) return true;
|
||||
BKE_group_unlink((Group *)id);
|
||||
BKE_group_unlink(mainlib, (Group *)id);
|
||||
break;
|
||||
case ID_OB:
|
||||
if (test) return true;
|
||||
BKE_object_unlink((Object *)id);
|
||||
BKE_object_unlink(mainlib, (Object *)id);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1205,7 +1205,11 @@ void BKE_libblock_free_us(Main *bmain, void *idv) /* test users */
|
|||
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);
|
||||
switch (GS(id->name)) {
|
||||
case ID_OB:
|
||||
BKE_object_unlink(bmain, (Object *)id);
|
||||
break;
|
||||
}
|
||||
|
||||
BKE_libblock_free(bmain, id);
|
||||
}
|
||||
|
|
|
@ -478,9 +478,8 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_object_unlink(Object *ob)
|
||||
void BKE_object_unlink(Main *bmain, Object *ob)
|
||||
{
|
||||
Main *bmain = G.main;
|
||||
Object *obt;
|
||||
Material *mat;
|
||||
World *wrld;
|
||||
|
|
|
@ -521,12 +521,13 @@ void OBJECT_OT_group_remove(wmOperatorType *ot)
|
|||
|
||||
static int group_unlink_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Group *group = CTX_data_pointer_get_type(C, "group", &RNA_Group).data;
|
||||
|
||||
if (!group)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
BKE_group_unlink(group);
|
||||
BKE_group_unlink(bmain, group);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL);
|
||||
|
||||
|
|
|
@ -215,8 +215,9 @@ static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEle
|
|||
}
|
||||
}
|
||||
|
||||
static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
||||
TreeStoreElem *tsep, TreeStoreElem *tselem)
|
||||
static void unlink_group_cb(
|
||||
bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te),
|
||||
TreeStoreElem *tsep, TreeStoreElem *tselem)
|
||||
{
|
||||
Group *group = (Group *)tselem->id;
|
||||
|
||||
|
@ -227,7 +228,8 @@ static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEleme
|
|||
}
|
||||
}
|
||||
else {
|
||||
BKE_group_unlink(group);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
BKE_group_unlink(bmain, group);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ static void rna_Main_objects_remove(Main *bmain, ReportList *reports, PointerRNA
|
|||
{
|
||||
Object *object = object_ptr->data;
|
||||
if (ID_REAL_USERS(object) <= 0) {
|
||||
BKE_object_unlink(object); /* needed or ID pointers to this are not cleared */
|
||||
BKE_object_unlink(bmain, object); /* needed or ID pointers to this are not cleared */
|
||||
BKE_libblock_free(bmain, object);
|
||||
RNA_POINTER_INVALIDATE(object_ptr);
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ static Group *rna_Main_groups_new(Main *bmain, const char *name)
|
|||
static void rna_Main_groups_remove(Main *bmain, PointerRNA *group_ptr)
|
||||
{
|
||||
Group *group = group_ptr->data;
|
||||
BKE_group_unlink(group);
|
||||
BKE_group_unlink(bmain, group);
|
||||
BKE_libblock_free(bmain, group);
|
||||
RNA_POINTER_INVALIDATE(group_ptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue