Data loss between saves for custom node trees #36024

Closed
opened 2013-07-05 20:45:09 +02:00 by Paul Kilgo · 4 comments

%%%--- Operating System, Graphics card ---
Ubuntu 13.04, Radeon HD 5000/6000/7350 Series

- Blender version with error, and version that worked ---

Nightly build, r58014
2.68-RC

No known working version.

- Short description of error ---

Between saves, Blender appears to lose node tree/node data when using a simple custom node editor.

- Steps for others to reproduce the error (preferably based on attached .blend file) ---
  1. Install and enable nodetest.py as an add-on for blender, save user preferences
  2. Open example.blend
  3. Make some changes (add/duplicate nodes) and save (either save over, save as, save copy, does not seem to matter)
  4. Close/reopen blender
  5. Open example.blend again, or a copy of it.

Expected behavior: changes persist

Observed behavior: node tree and nodes are missing
%%%

%%%--- Operating System, Graphics card --- Ubuntu 13.04, Radeon HD 5000/6000/7350 Series - Blender version with error, and version that worked --- Nightly build, r58014 2.68-RC No known working version. - Short description of error --- Between saves, Blender appears to lose node tree/node data when using a simple custom node editor. - Steps for others to reproduce the error (preferably based on attached .blend file) --- 1. Install and enable nodetest.py as an add-on for blender, save user preferences 2. Open example.blend 3. Make some changes (add/duplicate nodes) and save (either save over, save as, save copy, does not seem to matter) 4. Close/reopen blender 5. Open example.blend again, or a copy of it. Expected behavior: changes persist Observed behavior: node tree and nodes are missing %%%
Author

Changed status to: 'Open'

Changed status to: 'Open'

%%%This is standard Blender behavior, if a datablock has 0 users (as shown in the node menu), it will be removed by the garbage collector the next time you load the file. The same happens for materials, textures, meshes, .. . You can press the F (fake user) button to keep the nodes even if there is not other datablock using this node.

There is a big missing feature in the python API though, which is that you can't actually define create such links between datablocks yet. Hopefully that will be added soon, for now I guess the workaround is to enable the F button.
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.67/Python_Nodes%%%

%%%This is standard Blender behavior, if a datablock has 0 users (as shown in the node menu), it will be removed by the garbage collector the next time you load the file. The same happens for materials, textures, meshes, .. . You can press the F (fake user) button to keep the nodes even if there is not other datablock using this node. There is a big missing feature in the python API though, which is that you can't actually define create such links between datablocks yet. Hopefully that will be added soon, for now I guess the workaround is to enable the F button. http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.67/Python_Nodes%%%
Member

%%%Yes, the issue with missing data block references (pointer properties) needs to be solved. However, it is not the actual issue in this case.

The problem has 2 parts:

  1. The node editor space has a pointer property to the currently edited node tree. The type of node tree is checked for validity on loading, i.e. if the type of the linked node tree is not registered it gets reset to NULL. Now, when an addon is not enabled globally but only in a specific file all the types it registers only get registered after the data is loaded, at which point the node editor tree is already reset.

This behavior was a precaution to avoid invalid data access, but should not actually be needed any longer. The editor will just display dummy nodes in flashy red warning color in case the types really don't get registered after loading.

  1. For standard trees this pointer usually gets set from context based on the active material etc. (you can implement that for pynodes as well using - ). In that case the node editor space does not increment the user count, as it just references data from the context. But in the case of custom pynode trees from bpy.data.node_groups these trees are not actually referenced anywhere else - so the data blocks are considered unused and get discarded. For now i've changed user counting in the editor along the same lines as image editor: add an "real" user for the editor to avoid losing transient, unlinked data blocks.

Ultimately of course we want to link such trees in other places, at which point the bpy pointer property enters again. If you are interested, i've made a little workaround for "simulating" such properties (- [x], see IDRefProperty function and IDRefContainer decorator), example usage in - [x]. They simply store the name string and wrap a python property around it to return a true pointer, depending on property option also sets fake user by default to avoid user count problems.

The bug is fixed in SVN. Thanks for reporting!

%%%Yes, the issue with missing data block references (pointer properties) needs to be solved. However, it is not the actual issue in this case. The problem has 2 parts: 1) The node editor space has a pointer property to the currently edited node tree. The type of node tree is checked for validity on loading, i.e. if the type of the linked node tree is not registered it gets reset to NULL. Now, when an addon is not enabled globally but only in a specific file all the types it registers only get registered *after* the data is loaded, at which point the node editor tree is already reset. This behavior was a precaution to avoid invalid data access, but should not actually be needed any longer. The editor will just display dummy nodes in flashy red warning color in case the types really don't get registered after loading. 2) For standard trees this pointer usually gets set from context based on the active material etc. (you can implement that for pynodes as well using - [x]). In that case the node editor space does not increment the user count, as it just references data from the context. But in the case of custom pynode trees from bpy.data.node_groups these trees are not actually referenced anywhere else - so the data blocks are considered unused and get discarded. For now i've changed user counting in the editor along the same lines as image editor: add an "real" user for the editor to avoid losing transient, unlinked data blocks. Ultimately of course we want to link such trees in other places, at which point the bpy pointer property enters again. If you are interested, i've made a little workaround for "simulating" such properties (- [x], see IDRefProperty function and IDRefContainer decorator), example usage in - [x]. They simply store the name string and wrap a python property around it to return a true pointer, depending on property option also sets fake user by default to avoid user count problems. The bug is fixed in SVN. Thanks for reporting! - [x] http://www.blender.org/documentation/blender_python_api_2_67_1/bpy.types.NodeTree.html#bpy.types.NodeTree.get_from_context - [x] https://www.gitorious.org/blender-trunk/addons/blobs/geometry_nodes/py/scripts/addons/geometry_nodes/util.py - [x] https://www.gitorious.org/blender-trunk/addons/blobs/geometry_nodes/py/scripts/addons/geometry_nodes/node_group.py%%%
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
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 project
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#36024
No description provided.