diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-10-22 19:19:37 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-10-22 19:19:37 +0400 |
commit | 8bb39a536b741e1ccf55fb4cef6b5f580393c2b9 (patch) | |
tree | 8891537b9f78c1634a1016f1f764a577b164d23d | |
parent | df553892c9d2f034659e328e9286c1cf6a9554d7 (diff) |
Making real need to remove proxies
Otherwise some invalid pointers will be left
which could be harmless if real object stays
local, but crashes when linking them to
another files.
Was discovered here in the studio during
Project Pampa, and the steps to reproduce are:
- Create lib.blend, put armature and cube to it.
Create a group with them.
- Create scene.blend and link group from lib.blend.
- Make a proxy from armature.
- Make group real.
- Add real objects to a group.
- Create comp.blend and link group from scene.blend.
This step will creah.
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 5 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 14 |
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d277d25294e..bef0263b2f5 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1302,6 +1302,11 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, int copy_caches) obn->mode = 0; obn->sculpt = NULL; + /* Proxies are not to be copied. */ + obn->proxy_from = NULL; + obn->proxy_group = NULL; + obn->proxy = NULL; + /* increase user numbers */ id_us_plus((ID *)obn->data); id_us_plus((ID *)obn->gpd); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index db68a0eca4d..db75acef267 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1220,9 +1220,11 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, const short use_base_parent, const short use_hierarchy) { + Main *bmain = CTX_data_main(C); ListBase *lb; DupliObject *dob; GHash *dupli_gh = NULL, *parent_gh = NULL; + Object *object; if (!(base->object->transflag & OB_DUPLI)) return; @@ -1237,6 +1239,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, for (dob = lb->first; dob; dob = dob->next) { Base *basen; Object *ob = BKE_object_copy(dob->ob); + /* font duplis can have a totcol without material, we get them from parent * should be implemented better... */ @@ -1330,6 +1333,17 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, } } + /* The same how BKE_object_unlink detects which object proxies to clear. */ + if (base->object->transflag & OB_DUPLIGROUP && base->object->dup_group) { + for (object = bmain->object.first; object; object = object->id.next) { + if (object->proxy_group == base->object) { + object->proxy = NULL; + object->proxy_from = NULL; + DAG_id_tag_update(&object->id, OB_RECALC_OB); + } + } + } + if (dupli_gh) BLI_ghash_free(dupli_gh, NULL, NULL); if (parent_gh) |