Fix #102103: Copy/Paste of nodes is not handling ID references properly. #3

Closed
Bastien Montagne wants to merge 1 commits from tmp-node-copypaste into tmp-libquery-subdata-foreachid

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

This commit fixes several critical issues with previous code:

  • It only covered a (very small) subset of potential ID references in a
    node (namely, just the bNode::id pointer).
  • It completely ignored linked data case.
  • It would modify ID pointers in the clipboard itself.

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 and
generically process all ID pointers of a node.

The paste handling of ID pointers is split in two steps:

  • All knowns ID references are searched for in current Main data-base,
    and the result (current valid ID pointer or null if not found) is
    stored temporarily in the ID references mapping.
  • Once a node has been duplicated from the clipboard into the paste
    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).

This commit fixes several critical issues with previous code: * It only covered a (very small) subset of potential ID references in a node (namely, just the `bNode::id` pointer). * It completely ignored linked data case. * It would modify ID pointers in the clipboard itself. 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 and generically process all ID pointers of a node. The paste handling of ID pointers is split in two steps: * All knowns ID references are searched for in current Main data-base, and the result (current valid ID pointer or null if not found) is stored temporarily in the ID references mapping. * Once a node has been duplicated from the clipboard into the paste 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).
Bastien Montagne added 1 commit 2024-04-26 12:46:46 +02:00
This commit fixes several critical issues with previous code:
* It only covered a (very small) subset of potential ID references in a
  node (namely, just the `bNode::id` pointer).
* It completely ignored linked data case.
* It would modify ID pointers in the clipboard itself.

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 and
generically process all ID pointers of a node.

The paste handling of ID pointers is split in two steps:
* All knowns ID references are searched for in current Main data-base,
  and the result (current valid ID pointer or null if not found) is
  stored temporarily in the ID references mapping.
* Once a node has been duplicated from the clipboard into the paste
  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).
Bastien Montagne closed this pull request 2024-04-26 12:47:35 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mont29/blender#3
No description provided.