Fix T96844: Crash when switching workspaces and outliner modes

Error exposed by ba49345705. Code just assumed that the tree-element
pointed to a real ID, but this is often not the case, and the ID pointer
contains completely different data. E.g. before ba49345705, it would
be a pointer to one of the `Main` listbases, so this code would have
undefined behavior. Now the pointer is null for elements in the "Current
File" element, causing a null-pointer dereference rather than undefined
behavior (that just happened to virtually always result in the intended
code path).
This commit is contained in:
Julian Eisel 2022-03-29 15:17:25 +02:00
parent fced604acf
commit 4a5cd4e6c7
Notes: blender-bot 2023-02-14 04:31:04 +01:00
Referenced by issue #96844, Crash when trying to switch between workspaces and outliner modes
1 changed files with 2 additions and 1 deletions

View File

@ -712,7 +712,8 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
else {
/* do not extend Armature when we have posemode */
tselem = TREESTORE(te->parent);
if (GS(tselem->id->name) == ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE) {
if (TSE_IS_REAL_ID(tselem) && GS(tselem->id->name) == ID_OB &&
((Object *)tselem->id)->mode & OB_MODE_POSE) {
/* pass */
}
else {