Fix #120103: crash pasting geonodes referencing an ID into new file #120576

Closed
Philipp Oeser wants to merge 2 commits from lichtwerk/blender:120103 into main

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

The was already functionality for checking bNode.id when pasting
(reassigning IDs -- name-based -- when not in a new file), but we can
also have IDs referenced in sockets (e.g. SOCKET_OBJECT) and these were
not handled leading to crashes since the sockets were just duplicated.

Now also do what is done with bNode.id with IDs referenced in sockets.

NOTE: unsure if we should increment usercount here (but apparently
bNode.id also does not do it)
NOTE: there is a bit of duplicated code (but since assigning directly to
socket.default_value didnt update properly had to go through typed
socket values)
NOTE: introduces NodeClipboardItemIDInfo which could also be used for
the handling of bNode.id

The was already functionality for checking bNode.id when pasting (reassigning IDs -- name-based -- when not in a new file), but we can also have IDs referenced in sockets (e.g. SOCKET_OBJECT) and these were not handled leading to crashes since the sockets were just duplicated. Now also do what is done with bNode.id with IDs referenced in sockets. NOTE: unsure if we should increment usercount here (but apparently bNode.id also does not do it) NOTE: there is a bit of duplicated code (but since assigning directly to socket.default_value didnt update properly had to go through typed socket values) NOTE: introduces NodeClipboardItemIDInfo which could also be used for the handling of bNode.id
Philipp Oeser added 1 commit 2024-04-12 15:54:27 +02:00
c649457573 Fix #120103: crash pasting geonodes referencing an ID into new file
The was already functionality for checking bNode.id when pasting
(reassigning IDs -- name-based -- when not in a new file), but we can
also have IDs referenced in sockets (e.g. SOCKET_OBJECT) and these were
not handled leading to crashes since the sockets were just duplicated.

Now also do what is done with bNode.id with IDs referenced in sockets.

NOTE: unsure if we should increment usercount here (but apparently
bNode.id also does not do it)
NOTE: there is a bit of duplicated code (but since assigning directly to
socket.default_value didnt update properly had to go through typed
socket values)
NOTE: introduces NodeClipboardItemIDInfo which could also be used for
the handling of bNode.id
Philipp Oeser added the
Interest
ID Management
label 2024-04-12 15:54:40 +02:00
Philipp Oeser added this to the Nodes & Physics project 2024-04-12 15:54:46 +02:00
Philipp Oeser added the
Interest
Geometry Nodes
label 2024-04-12 15:54:53 +02:00
Philipp Oeser requested review from Hans Goudey 2024-04-12 15:55:01 +02:00
Philipp Oeser requested review from Bastien Montagne 2024-04-12 15:55:14 +02:00
Hans Goudey requested changes 2024-04-12 16:49:42 +02:00
Hans Goudey left a comment
Member

Overall this fix makes sense, but I'd suggest pushing the changes a bit further to reduce code duplication and boilerplate. Some ideas:

  • Add a local function that gives the ID ** pointer in a socket
  • Move the existing library information to use the new struct
  • Add utility functions to create the ID info struct and to remap an ID pointer later on
Overall this fix makes sense, but I'd suggest pushing the changes a bit further to reduce code duplication and boilerplate. Some ideas: - Add a local function that gives the `ID **` pointer in a socket - Move the existing library information to use the new struct - Add utility functions to create the ID info struct and to remap an ID pointer later on
Philipp Oeser added 1 commit 2024-04-12 17:34:02 +02:00
Bastien Montagne requested changes 2024-04-12 17:47:43 +02:00
Bastien Montagne left a comment
Owner

Yet another case of 'custom handling' of ID pointers... ;(

I think this fix would be a good opportunity to fix it properly - which means using the generic 'foreach_id' system.

From a quick look, node_foreach_id should be refactored to split out in a new function the handling of a single node, and that new function should be made public, for the node paste code to use it and handle all potential ID pointers (looks like current PR would at the very least still miss IDProperties ?).

I would also rather store, in the clipboard data, a mapping of all ID pointers found (something like orig_id_pointer -> (id_name, id_library, optional_new_id_pointer)). That way, handling of ID pointers can be fully generic, and lookup based on ID name/library path can be done only once. Further more, the generic foreach_id code will gives info, like whether the currently processed pointer should affect usercounts or not, etc.

Note that I don't think we have other use-cases of using the foreach_id system on a sub-part of an ID, this may require some work to get it working properly...

Yet another case of 'custom handling' of ID pointers... ;( I think this fix would be a good opportunity to fix it properly - which means using the generic 'foreach_id' system. From a quick look, `node_foreach_id` should be refactored to split out in a new function the handling of a single node, and that new function should be made public, for the node paste code to use it and handle _all_ potential ID pointers (looks like current PR would at the very least still miss IDProperties ?). I would also rather store, in the clipboard data, a mapping of all ID pointers found (something like `orig_id_pointer -> (id_name, id_library, optional_new_id_pointer)`). That way, handling of ID pointers can be fully generic, and lookup based on ID name/library path can be done only once. Further more, the generic foreach_id code will gives info, like whether the currently processed pointer should affect usercounts or not, etc. Note that I don't think we have other use-cases of using the foreach_id system on a sub-part of an ID, this may require some work to get it working properly...
Author
Member

Sounds like a bigger project :) but yeah, will give it a go next week...

Sounds like a bigger project :) but yeah, will give it a go next week...
Author
Member

Will close in favor of !121122

Will close in favor of !121122
Philipp Oeser closed this pull request 2024-04-26 13:34:18 +02:00

Pull request closed

Sign in to join this conversation.
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 Assignees
3 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: blender/blender#120576
No description provided.