Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dalai@blender.org>2021-10-08 17:01:49 +0300
committerDalai Felinto <dalai@blender.org>2021-10-08 17:17:08 +0300
commit38c4888f0999ee5361dc76d2b9a7cd45e8ae2896 (patch)
treeffbf77aae33dd2c33d5f4c78d65b37f877a9bf6d /source/blender/editors/space_node
parent0c684a704641fdd3cf46f263464b8f84060f79e6 (diff)
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
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r--source/blender/editors/space_node/node_draw.cc12
1 files changed, 3 insertions, 9 deletions
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);
}