Fix T50013: Blender 2.78a Link/Append Crash.

Object freeing may in some kind access its obdata (in case it has some
caches e.g.), since here obdata may have already been freed, let's set
object's data pointer to NULL (probably not ideal solution, but we don't
care much, those form archipelagos of unused linked datablocks,
we nuke'em all anyway).

Also fix stupid mistake in one of own recent commits (using ID we just
freed, tsst...).
This commit is contained in:
Bastien Montagne 2016-11-13 15:49:41 +01:00
parent 7e8bf9dbd6
commit 1b1d6ce131
Notes: blender-bot 2023-02-14 07:24:41 +01:00
Referenced by issue #50013, Blender 2.78a Link/Append Crash
1 changed files with 6 additions and 1 deletions

View File

@ -1841,6 +1841,12 @@ void BKE_library_make_local(
/* Note: in theory here we are only handling datablocks forming exclusive linked dependency-cycles-based
* archipelagos, so no need to check again after we have deleted one, as done in previous step. */
if (id->tag & LIB_TAG_DOIT) {
/* Object's deletion rely on valid ob->data, but ob->data may have already been freed here...
* Setting it to NULL may not be 100% correct, but should be safe and do the work. */
if (GS(id->name) == ID_OB) {
((Object *)id)->data = NULL;
}
/* Note: *in theory* IDs tagged here are fully *outside* of file scope, totally unused, so we can
* directly wipe them out without caring about clearing their usages.
* However, this is a highly-risky presumption, and nice crasher in case something goes wrong here.
@ -1853,7 +1859,6 @@ void BKE_library_make_local(
#endif
((LinkNode *)it->link)->link = NULL; /* Not strictly necessary, but safer (see T49903)... */
it->link = NULL;
id->tag &= ~LIB_TAG_DOIT;
}
}