Page MenuHome

Cleanup: Simplify node clipboard, use Vector instead of ListBase
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Dec 29 2022, 2:57 AM.

Details

Summary
  • Move from blenkernel to the node editor, the only place it was used
  • Use two vectors instead of ListBase
  • Remove define for validating the clipboard, which shouldn't be skipped

Diff Detail

Repository
rB Blender

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Dec 29 2022, 2:57 AM
Hans Goudey (HooglyBoogly) created this revision.
Jacques Lucke (JacquesLucke) requested changes to this revision.Dec 29 2022, 2:00 PM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/editors/space_node/clipboard.cc
40

Use the Construct on First Use idiom for all static variables that might use the guarded allocator, i.e. put this into a function that returns the clipboard reference.

42

Looks like this method and the once below might make sense as methods on the clipboard?

60

Since you are changing the code a fair amount (more than just moving it around), you should also improve the comment style imo.

This revision now requires changes to proceed.Dec 29 2022, 2:00 PM
Hans Goudey (HooglyBoogly) marked 3 inline comments as done.
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)

Thanks for the comments!

  • Use construct on first use pattern
  • Move functions to class methods
  • Some further cleanup: Use references, comment style
Jacques Lucke (JacquesLucke) requested changes to this revision.Dec 29 2022, 7:26 PM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/editors/space_node/clipboard.cc
52

Would be nice if the description could say a bit more about what is actually validated.

63

This crashes in a debug build for me, because G_MAIN is null when ED_node_clipboard_free is called.

95

Missing static

This revision now requires changes to proceed.Dec 29 2022, 7:26 PM
Hans Goudey (HooglyBoogly) marked 3 inline comments as done.Dec 29 2022, 9:11 PM
Hans Goudey (HooglyBoogly) added inline comments.
source/blender/editors/space_node/clipboard.cc
52

I added a bit more info, from what I could tell. It seems wrong to me honestly, it sets library_name but it doesn't use the value. But that's what it did before, and I don't really want to get into it right now.

Hans Goudey (HooglyBoogly) marked an inline comment as done.
  • Fix crash on exit
  • Add more info to comment
  • Add static to function
  • Remove "b" prefix on clipboard struct
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/editors/space_node/clipboard.cc
63

This check doesn't make sense because it will be non-null even if G_MAIN is null.

This revision is now accepted and ready to land.Dec 29 2022, 9:59 PM