[Bf-blender-cvs] [38c4888f099] master: Fix crash in the node editor in cases where nodetree was empty
Dalai Felinto
noreply at git.blender.org
Fri Oct 8 16:17:12 CEST 2021
Commit: 38c4888f0999ee5361dc76d2b9a7cd45e8ae2896
Author: Dalai Felinto
Date: Fri Oct 8 16:01:49 2021 +0200
Branches: master
https://developer.blender.org/rB38c4888f0999ee5361dc76d2b9a7cd45e8ae2896
Fix crash in the node editor in cases where nodetree was empty
This seems to happen only in a few files, and not so trivial to
reproduce from scratch.
The crash is real though, and this fixes it.
It also fix a wrong comment style that was introduced in the same faulty
commit.
Bug introduced on ebe23745281e86.
Differential Revision: https://developer.blender.org/D12794
===================================================================
M source/blender/editors/space_node/node_draw.cc
===================================================================
diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc
index bcebd73e9a7..c864f6c34d6 100644
--- a/source/blender/editors/space_node/node_draw.cc
+++ b/source/blender/editors/space_node/node_draw.cc
@@ -2178,22 +2178,16 @@ static void draw_nodetree(const bContext *C,
/**
* Make the background slightly brighter to indicate that users are inside a nodegroup.
- **/
+ */
static void draw_background_color(const SpaceNode *snode)
{
const int max_depth = 2;
const float bright_factor = 0.25f;
+ const int depth = BLI_listbase_count_at_most(&snode->treepath, max_depth);
+
float color[3];
UI_GetThemeColor3fv(TH_BACK, color);
-
- int depth = 0;
- bNodeTreePath *path = (bNodeTreePath *)snode->treepath.last;
- while (path->prev && depth < max_depth) {
- path = path->prev;
- depth++;
- }
-
mul_v3_fl(color, 1.0f + bright_factor * depth);
GPU_clear_color(color[0], color[1], color[2], 1.0);
}
More information about the Bf-blender-cvs
mailing list