Page MenuHome

Cleanup: Use Map instead of GHash for node type hashes (WIP)
Needs ReviewPublic

Authored by Hans Goudey (HooglyBoogly) on Feb 3 2021, 3:03 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This gives better type safety, ease of use (at least in C++ code), and
better readability. The downside is that C code becomes uglier, since
it doesn't have lambdas.

Diff Detail

Repository
rB Blender
Branch
cleanup-node-cc-use-map (branched from master)
Build Status
Buildable 18635
Build 18635: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Feb 3 2021, 3:03 AM
Hans Goudey (HooglyBoogly) created this revision.
source/blender/blenkernel/intern/node.cc
1403

Here you make the assumption that there will always be at least one element in the iterator. While it might be true, for this specific case, this isn't something you should assume.

1406

Should take the map as reference.

1491

You don't know yet if you can safely dereference the iterator that you just incremented.

Hans Goudey (HooglyBoogly) marked 3 inline comments as done.

Thanks, that did it. Checked it by enabling and disabling a node based addon.

  • Take the map as reference in constructors
  • Check if the end has been reached before dereferencing
source/blender/blenkernel/intern/node.cc
1418

The fact that you have to compare to iterator->end in all of these functions indicates that the approach does not seem quite right. I think it should be possible to only have this check in one of the functions, while still being correct. Maybe you need to use a different set of functions.

Refactor to avoid iterators, use foreach callbacks instead

This makes C code (rna_nodetree.c) more ugly but it seems like a good direction.
I also removed some unused RNA functions to avoid having to reimplement them.

Currently there is a crash, but I'm finding it difficult to debug.
I think it has to do with the way I'm using FunctionRef.

Hans Goudey (HooglyBoogly) retitled this revision from WIP: Cleanup: Use Map instead of GHash for node type hashes to Cleanup: Use Map instead of GHash for node type hashes (WIP).Nov 13 2021, 12:01 AM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)

Fix incorrec types in C code. Blender seems to work correctly now, but enabling
and disabling sverchok a few times still causes some issues.