From fdc9412b9d805397cf4676071091b92e6192d959 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 22 Sep 2025 17:40:38 +0200 Subject: [PATCH] Fix: Appending a workspace appends scene data along with it This probably got broken when expanding was changed to use foreach ID. In the old code the screen was not part of expanding. Also adds the appropriate flags for workspace pinned and sequencer scenes. This was causing issues in particular with the new video editing template, where appending a workspace would append the Edit scene. Fix #146156 Pull Request: https://projects.blender.org/blender/blender/pulls/146164 --- source/blender/blenkernel/intern/workspace.cc | 4 ++-- source/blender/blenloader/intern/readfile.cc | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/workspace.cc b/source/blender/blenkernel/intern/workspace.cc index c5d6d4c092a..c8f2d4a9dd2 100644 --- a/source/blender/blenkernel/intern/workspace.cc +++ b/source/blender/blenkernel/intern/workspace.cc @@ -70,8 +70,8 @@ static void workspace_foreach_id(ID *id, LibraryForeachIDData *data) { WorkSpace *workspace = (WorkSpace *)id; - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, workspace->pin_scene, IDWALK_CB_NOP); - BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, workspace->sequencer_scene, IDWALK_CB_NOP); + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, workspace->pin_scene, IDWALK_CB_DIRECT_WEAK_LINK); + BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, workspace->sequencer_scene, IDWALK_CB_DIRECT_WEAK_LINK); LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) { BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, layout->screen, IDWALK_CB_USER); diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index 7f9c8690c9f..375b03fe105 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -4443,6 +4443,12 @@ static int expand_cb(LibraryIDLinkCallbackData *cb_data) return IDWALK_RET_NOP; } + /* Do not expand weak links. These are used when the user interface links to scene data, + * but we don't want to bring along such datablocks with a workspace. */ + if (cb_data->cb_flag & IDWALK_CB_DIRECT_WEAK_LINK) { + return IDWALK_RET_NOP; + } + /* Explicitly requested to be ignored during readfile processing. Means the read_data code * already handled this pointer. Typically, the 'owner_id' pointer of an embedded ID. */ if (cb_data->cb_flag & IDWALK_CB_READFILE_IGNORE) {