From c0ba1671c34683654b691684473bb4f3899604a7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 13 Jul 2010 16:53:17 +0000 Subject: group refcount checking was inconsistent. - if a group has one or more objects in it, it gets a refcount of 1 on load (unchanged from before) - dupli-groups, and materials no longer add/remove a reference. - now groups are only freed when they contain no objects or when manually unlinked. --- source/blender/editors/object/object_add.c | 3 +-- source/blender/editors/object/object_edit.c | 2 +- source/blender/editors/object/object_relations.c | 3 +-- source/blender/editors/space_outliner/outliner.c | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 757c167c496..2299207eaa9 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -754,8 +754,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) rename_id(&ob->id, group->id.name+2); ob->dup_group= group; ob->transflag |= OB_DUPLIGROUP; - id_us_plus(&group->id); - + id_lib_extern(&group->id); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index d3226b1adf4..5fe09f0083e 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1408,7 +1408,7 @@ void copy_attr(Scene *scene, View3D *v3d, short event) base->object->dup_group= ob->dup_group; if(ob->dup_group) - id_us_plus((ID *)ob->dup_group); + id_lib_extern(&ob->dup_group->id); } else if(event==7) { /* mass */ base->object->mass= ob->mass; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index fbc6075796c..8d488eeabac 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1250,10 +1250,9 @@ static int make_links_data_exec(bContext *C, wmOperator *op) BKE_copy_animdata_id((ID *)obt->data, (ID *)ob->data); break; case MAKE_LINKS_DUPLIGROUP: - if(ob->dup_group) ob->dup_group->id.us--; obt->dup_group= ob->dup_group; if(obt->dup_group) { - id_us_plus((ID *)obt->dup_group); + id_lib_extern(&obt->dup_group->id); obt->transflag |= OB_DUPLIGROUP; } break; diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index 794c700f8ce..95e2cb920fc 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -1411,7 +1411,7 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) GroupObject *go; for(group= mainvar->group.first; group; group= group->id.next) { - if(group->id.us) { + if(group->gobject.first) { te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); tselem= TREESTORE(te); @@ -3124,7 +3124,6 @@ static void unlink_group_cb(bContext *C, Scene *scene, TreeElement *te, TreeStor if( GS(tsep->id->name)==ID_OB) { Object *ob= (Object *)tsep->id; ob->dup_group= NULL; - group->id.us--; } } else { -- cgit v1.2.3