From 37c0b2c47d56c77df730fc41da6ef20408e1ef69 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Mon, 17 Feb 2025 20:03:22 +0100 Subject: [PATCH] Fix #134592: Node Editor space_*_get Unregistered Tree Type Returns When needing a friendly title and icon for windows and screen areas we use SpaceType callbacks. For Node editors this could crash for custom node trees that are unregistered. node_tree_type_find returns nullptr since this custom tree type is not in the map. In this case just return translated "Node Editor". Pull Request: https://projects.blender.org/blender/blender/pulls/134692 --- source/blender/editors/space_node/space_node.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index dc2f56ce36d..a7bb07b82fe 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -38,6 +38,8 @@ #include "BKE_node_tree_zones.hh" #include "BKE_screen.hh" +#include "BLT_translation.hh" + #include "ED_image.hh" #include "ED_node.hh" #include "ED_node_preview.hh" @@ -1344,6 +1346,9 @@ static blender::StringRefNull node_space_name_get(const ScrArea *area) { SpaceNode *snode = static_cast(area->spacedata.first); bke::bNodeTreeType *tree_type = bke::node_tree_type_find(snode->tree_idname); + if (tree_type == nullptr) { + return IFACE_("Node Editor"); + } return tree_type->ui_name; } @@ -1351,6 +1356,9 @@ static int node_space_icon_get(const ScrArea *area) { SpaceNode *snode = static_cast(area->spacedata.first); bke::bNodeTreeType *tree_type = bke::node_tree_type_find(snode->tree_idname); + if (tree_type == nullptr) { + return ICON_NODETREE; + } return tree_type->ui_icon; }