Fix #120103: Copy/Paste of nodes is not handling ID references properly. #121122
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#121122
Loading…
Reference in New Issue
No description provided.
Delete Branch "mont29/blender:tmp-node-copypaste"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This commit fixes several critical issues with previous code:
node (namely, just the
bNode::id
pointer).The new code stores ID reference info in a separate mapping. It uses the
new 'sub-data' foreach_id feature from
BKE_lib_query
to reliably andgenerically process all ID pointers of a node.
The paste handling of ID pointers is split in two steps:
and the result (current valid ID pointer or null if not found) is
stored temporarily in the ID references mapping.
destination nodetree, its ID pointers are updated accordingly.
This allows to keep the 'reference ID' data in the clipboard always
valid, regardless of which IDs are currently existing in Main (i.e. to
keep all available data, even when opening new blendfiles, or doing
undo/redo that would affect the existing IDs).
NOTE: Depends on (and contains) !121018
@blender-bot build
dab19d2a63
tod64274bb08
Fix #102103: Copy/Paste of nodes is not handling ID references properly.to Fix #120103: Copy/Paste of nodes is not handling ID references properly.@blender-bot build
Functionality works fine from the tests I previously had with #120103.
For the code-side: I wont dive into this due to time-constraints
d64274bb08
to420948d966
Only found one major issue which I reported in #121018. Otherwise LGTM.
@ -26,2 +28,4 @@
namespace blender::ed::space_node {
struct NodeClipboardItemIDInfo {
/* Name and library filepath form a unique identifer for a given ID. */
Comment style:
/**
. Same in a few places below.@ -27,1 +29,4 @@
struct NodeClipboardItemIDInfo {
/* Name and library filepath form a unique identifer for a given ID. */
std::string id_name = "";
It's not really necessary to write these initializers for
std::string
andstd::optional
. They are always default-constructed anyway.I know, but I find it cleaner/more readable to be explicit about default values...
@ -28,0 +30,4 @@
struct NodeClipboardItemIDInfo {
/* Name and library filepath form a unique identifer for a given ID. */
std::string id_name = "";
/* Note: Library reference is stored as an absolute path. Since the Node clippboard is runtime
typo (
clippboard
)@ -58,0 +81,4 @@
*
* DO NOT update the nodes' pointers here though, as this would affect the clipboard content,
* which is no desired here. It should remain as in original state, such that e.g. one can copy
* nodes in file `A.blend`, open file `B.blend`, paste nodes (and lose some of the invlaid ID
typo (
invalid
)@ -83,0 +111,4 @@
* and libpath pairs can be used here.
* - UID cannot be trusted accross file load.
* - ID pointer itself cannot be trusted accross undo/redo and fileload. */
auto validate_id_fn = [this, &is_valid, &bmain, &bmain_id_map, &libraries_path_to_id](
It's ok to just use
&
if the lambda does not leave the current scope.Here as well, I find explicit capturing of required variables cleaner and more readable tbh
@blender-bot build
@blender-bot build