Fix T70965: Undo crash with specific file
Not sure how the WorkSpaceLayout.screen pointer could end up being NULL, but apparently that happens, or at least happened with older files. Rather than just adding NULL-checks, prefer not keeping around those invalid layouts at all.
This commit is contained in:
parent
c27acbcfb7
commit
ca49643f3c
Notes:
blender-bot
2023-02-14 00:25:58 +01:00
Referenced by issue #70965, Blender crashes when the ctrl+z (undo)
|
@ -247,8 +247,12 @@ WorkSpaceLayout *BKE_workspace_layout_add(Main *bmain,
|
|||
|
||||
void BKE_workspace_layout_remove(Main *bmain, WorkSpace *workspace, WorkSpaceLayout *layout)
|
||||
{
|
||||
id_us_min(&layout->screen->id);
|
||||
BKE_id_free(bmain, layout->screen);
|
||||
/* Screen should usually be set, but we call this from file reading to get rid of invalid
|
||||
* layouts. */
|
||||
if (layout->screen) {
|
||||
id_us_min(&layout->screen->id);
|
||||
BKE_id_free(bmain, layout->screen);
|
||||
}
|
||||
BLI_freelinkN(&workspace->layouts, layout);
|
||||
}
|
||||
|
||||
|
|
|
@ -3377,6 +3377,11 @@ static void lib_link_workspaces(FileData *fd, Main *bmain)
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* If we're reading a layout without screen stored, it's useless and we shouldn't keep it
|
||||
* around. */
|
||||
BKE_workspace_layout_remove(bmain, workspace, layout);
|
||||
}
|
||||
}
|
||||
|
||||
id->tag &= ~LIB_TAG_NEED_LINK;
|
||||
|
|
Loading…
Reference in New Issue