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.
This commit is contained in:
Sergey Sharybin
2013-10-22 15:19:37 +00:00
parent df553892c9
commit 8bb39a536b
2 changed files with 19 additions and 0 deletions

View File

@@ -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);

View File

@@ -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)