Fix T49905: Segfault when copying object data of linked object.

We have to clear `newid` of all datablocks, not only object ones.

Note that this whole stuff is still using some kind of older, primitive
'ID remapping', would like to see whether we can replace it with new,
more generic one, but that's for another day.
This commit is contained in:
Bastien Montagne 2016-11-04 09:55:46 +01:00
parent 17fb504bcf
commit f0ac661aa8
Notes: blender-bot 2023-02-14 19:44:16 +01:00
Referenced by issue blender/blender-addons#49905, Segfault when copying object data of linked object
1 changed files with 10 additions and 4 deletions

View File

@ -1740,10 +1740,16 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
clear_sca_new_poins(); /* sensor/contr/act */
/* newid may still have some trash from Outliner tree building,
* so clear that first to avoid errors [#26002] */
for (ob = bmain->object.first; ob; ob = ob->id.next)
ob->id.newid = NULL;
/* newid may still have some trash from Outliner tree building, so clear that first to avoid errors, see T26002.
* We have to clear whole datablocks, not only Object one may be accessed here, see T49905. */
ListBase *lbarray[MAX_LIBARRAY];
int a = set_listbasepointers(bmain, lbarray);
while (a--) {
ListBase *lb = lbarray[a];
for (ID *id = lb->first; id; id = id->next) {
id->newid = NULL;
}
}
/* duplicate (must set newid) */
for (base = FIRSTBASE; base; base = base->next) {