Fix T98753: Outliner Unlink material in Blender File mode crashes

This issue was only exposed by ba49345705. The ID pointer of the
material's parent tree-element wasn't actually pointing to an ID, but to
the list-base containing the IDs. It was just unlikely to cause issues
in practice, although an assert was thrown.

Just don't do anything if the object or object-data to unlink the
material from could not be found. The following commit will introduce a
error message about this.
This commit is contained in:
Julian Eisel 2022-06-14 15:51:03 +02:00
parent c7942c31b2
commit e772087ed6
Notes: blender-bot 2023-02-14 09:02:40 +01:00
Referenced by commit e97443478e, Fix T102797: Unlinking an Orphan Action crashes
Referenced by issue #98753, Regression: Outliner Unlink material crash Blender 3.2
Referenced by issue #98661, 3.2: Potential candidates for corrective releases
1 changed files with 6 additions and 0 deletions

View File

@ -229,6 +229,12 @@ static void unlink_material_fn(bContext *UNUSED(C),
TreeStoreElem *UNUSED(tselem),
void *UNUSED(user_data))
{
if (!tsep || !TSE_IS_REAL_ID(tsep)) {
/* Valid case, no parent element of the material or it is not an ID (could be a #TSE_ID_BASE
* for example) so there's no data to unlink from. */
return;
}
Material **matar = nullptr;
int a, totcol = 0;