From 0a35af2fc0347f64a386a18dcece585c7943c14a Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Fri, 10 Oct 2025 14:58:02 +0200 Subject: [PATCH] Fix #147623: Compositor: Impossible to toggle Asset Shelf In certain scenarios, the Node Editor lacks the `RGN_TYPE_ASSET_SHELF` & `RGN_TYPE_ASSET_SHELF_HEADER` regions. That is because the versioning code from 0a0dd4ca37ca only creates these for Node Editors that are Compositors. That does not seem right. The thing is, if you change a non-node Editor (e.g. an Image Editor) to a Compositor editor, all is fine (`SpaceLink *node_create` gets called, the regions set up correctly), but changing an **existing** node editor (e.g. Shader or Geometry Nodes) to a Compositor, no new Space gets set up (rightfully so) and we are then missing the regions. I dont really see an issue with having the versioning setting up shelf regions for **all** node editors (the shelf polls will already take care of it only showing in the Compositor) which is what this PR does. Now we are in the unfortunate situation that people might have saved their `startup.blend` (or other files affected by that) in the meantime, so versioning will not kick in anymore, so we probably have to do another versionbump (which will happen in `main`). Pull Request: https://projects.blender.org/blender/blender/pulls/147689 --- .../blenloader/intern/versioning_500.cc | 71 ++++++++++--------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_500.cc b/source/blender/blenloader/intern/versioning_500.cc index ad5e3a815db..8eb96a4ccd5 100644 --- a/source/blender/blenloader/intern/versioning_500.cc +++ b/source/blender/blenloader/intern/versioning_500.cc @@ -3287,39 +3287,12 @@ void blo_do_versions_500(FileData *fd, Library * /*lib*/, Main *bmain) } if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 46)) { - LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { - LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { - if (sl->spacetype != SPACE_NODE) { - continue; - } - const SpaceNode *snode = reinterpret_cast(sl); - if (!STREQ(snode->tree_idname, "CompositorNodeTree")) { - continue; - } - - ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : - &sl->regionbase; - - if (ARegion *new_shelf_region = do_versions_add_region_if_not_found( - regionbase, - RGN_TYPE_ASSET_SHELF, - "Asset shelf for compositing (versioning)", - RGN_TYPE_HEADER)) - { - new_shelf_region->alignment = RGN_ALIGN_BOTTOM; - } - if (ARegion *new_shelf_header = do_versions_add_region_if_not_found( - regionbase, - RGN_TYPE_ASSET_SHELF_HEADER, - "Asset shelf header for compositing (versioning)", - RGN_TYPE_ASSET_SHELF)) - { - new_shelf_header->alignment = RGN_ALIGN_BOTTOM | RGN_ALIGN_HIDE_WITH_PREV; - } - } - } - } + /* Versioning from 0a0dd4ca37 was wrong, it only created asset shelf regions for Node Editors + * that are Compositors. If you change a non-Node Editor (e.g. an Image Editor) to a Compositor + * Editor, all is fine (SpaceLink *node_create gets called, the regions set up correctly), but + * changing an existing Node Editor (e.g. Shader or Geometry Nodes) to a Compositor, no new + * Space gets set up (rightfully so) and we are then missing the regions. Now corrected below + * (version bump in 5.1 since that is also affected). */ } if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 48)) { @@ -3978,6 +3951,38 @@ void blo_do_versions_500(FileData *fd, Library * /*lib*/, Main *bmain) } } + if (!MAIN_VERSION_FILE_ATLEAST(bmain, 501, 2)) { + LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + if (sl->spacetype != SPACE_NODE) { + continue; + } + + ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : + &sl->regionbase; + + if (ARegion *new_shelf_region = do_versions_add_region_if_not_found( + regionbase, + RGN_TYPE_ASSET_SHELF, + "Asset shelf for compositing (versioning)", + RGN_TYPE_HEADER)) + { + new_shelf_region->alignment = RGN_ALIGN_BOTTOM; + } + if (ARegion *new_shelf_header = do_versions_add_region_if_not_found( + regionbase, + RGN_TYPE_ASSET_SHELF_HEADER, + "Asset shelf header for compositing (versioning)", + RGN_TYPE_ASSET_SHELF)) + { + new_shelf_header->alignment = RGN_ALIGN_BOTTOM | RGN_ALIGN_HIDE_WITH_PREV; + } + } + } + } + } + /** * Always bump subversion in BKE_blender_version.h when adding versioning * code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.