From 320c77b9635fbb2ced803759dd34b4f224d90e17 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 7 Nov 2024 15:41:39 +0100 Subject: [PATCH] Fix #123769: Assert when saving a file with deleted workspaces. Delete sceens when their workspace is deleted. Also remove `IDTYPE_FLAGS_NEVER_UNUSED` tag from bScreen ID type, there is no more point to keep these IDs around if they are not used, there are supposed to be mere sub-data of the Workspaces. Pull Request: https://projects.blender.org/blender/blender/pulls/129975 --- source/blender/blenkernel/intern/screen.cc | 2 +- source/blender/editors/screen/workspace_edit.cc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/screen.cc b/source/blender/blenkernel/intern/screen.cc index dd26686df16..2ddf9befe70 100644 --- a/source/blender/blenkernel/intern/screen.cc +++ b/source/blender/blenkernel/intern/screen.cc @@ -170,7 +170,7 @@ IDTypeInfo IDType_ID_SCR = { /*name_plural*/ N_("screens"), /*translation_context*/ BLT_I18NCONTEXT_ID_SCREEN, /*flags*/ IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_ONLY_APPEND | IDTYPE_FLAGS_NO_ANIMDATA | - IDTYPE_FLAGS_NO_MEMFILE_UNDO | IDTYPE_FLAGS_NEVER_UNUSED, + IDTYPE_FLAGS_NO_MEMFILE_UNDO, /*asset_type_info*/ nullptr, /*init_data*/ nullptr, diff --git a/source/blender/editors/screen/workspace_edit.cc b/source/blender/editors/screen/workspace_edit.cc index 982ca24c417..ce2c4fed0ba 100644 --- a/source/blender/editors/screen/workspace_edit.cc +++ b/source/blender/editors/screen/workspace_edit.cc @@ -257,6 +257,12 @@ bool ED_workspace_delete(WorkSpace *workspace, Main *bmain, bContext *C, wmWindo } } + /* Also delete managed sceens if they have no other users. */ + LISTBASE_FOREACH (WorkSpaceLayout *, layout, &workspace->layouts) { + BKE_id_free_us(bmain, layout->screen); + layout->screen = nullptr; + } + BKE_id_free(bmain, &workspace->id); return true; }