Skip to content
Snippets Groups Projects
Commit a274713f authored by Bastien Montagne's avatar Bastien Montagne Committed by Philipp Oeser
Browse files

Fix #105230: Crash when reloading a library when one of its scene is active.

Scene and viewlayers pointers in the link/append context data need to be
updated after reload, otherwise they would keep pointing to old freed
IDs.
parent 0e808041
Branches
Tags
No related merge requests found
...@@ -1545,6 +1545,24 @@ void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context, ...@@ -1545,6 +1545,24 @@ void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context,
continue; continue;
} }
/* In case the active scene was reloaded, the context pointers in
* `lapp_context->params->context` need to be updated before the old Scene ID is freed. */
if (old_id == &lapp_context->params->context.scene->id) {
BLI_assert(GS(old_id->name) == ID_SCE);
Scene *new_scene = (Scene *)item->new_id;
BLI_assert(new_scene != NULL);
lapp_context->params->context.scene = new_scene;
if (lapp_context->params->context.view_layer != NULL) {
ViewLayer *new_view_layer = BKE_view_layer_find(
new_scene, lapp_context->params->context.view_layer->name);
lapp_context->params->context.view_layer = (new_view_layer != NULL) ?
new_view_layer :
new_scene->view_layers.first;
}
/* lapp_context->params->context.v3d should never become invalid by newly linked data here.
*/
}
if (old_id->us == 0) { if (old_id->us == 0) {
old_id->tag |= LIB_TAG_DOIT; old_id->tag |= LIB_TAG_DOIT;
item->userdata = NULL; item->userdata = NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment