Inharitance for ShaderNodeCustomGroup is broken #71858

Open
opened 2019-11-24 15:41:46 +01:00 by Maxim Vasiliev · 14 comments

System Information
Operating system: Linux-5.0.0-36-generic-x86_64-with-debian-buster-sid 64 Bits
Graphics card: GeForce GT 730/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 418.56

Blender Version
Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-11-20 14:27, hash: 26bd5ebd42
Worked: (optional)

Short description of error
When a custom node class is inherited from a base class, it breaks the base clas.

class MyNodeBase(bpy.types.ShaderNodeCustomGroup):
    ...    

class FooNode(MyNodeBase):
    bl_idname="my.foo"
    bl_label = "foo"

class BarNode(MyNodeBase):
    # this get broken if any derved class exists
    bl_idname="my.bar"
    bl_label = "bar"

class BazNode(BarNode):
    # this works but breakes BarNode
    bl_idname="my.baz"
    bl_label = "baz"

Attempt of creating BarNode results in:

WARN (bpy.rna): /home/sources/buildbot-x86_64-slave/linux_glibc217_x86_64_cmake/blender.git/source/blender/python/intern/bpy_rna.c:8164 bpy_class_call: unable to get Python class for RNA struct 'my.bar'
Traceback (most recent call last):
  File "/home/qmax/Heap/3d/test.blend/nodes.py", line 23, in execute
RuntimeError: Error: Cannot add node of type my.bar to node tree 'Shader Nodetree'

Exact steps for others to reproduce the error

  • open attached file and execute packed nodes.py
  • call operator 'add bar' in shader editor

test.blend

Workaround

Register classes in reverse order: derived first, then base.

classes = (BazNode, BarNode, FooNode)

for c in classes:
  bpy.utils.register_class(c)
**System Information** Operating system: Linux-5.0.0-36-generic-x86_64-with-debian-buster-sid 64 Bits Graphics card: GeForce GT 730/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 418.56 **Blender Version** Broken: version: 2.81 (sub 16), branch: master, commit date: 2019-11-20 14:27, hash: `26bd5ebd42` Worked: (optional) **Short description of error** When a custom node class is inherited from a base class, it breaks the base clas. ``` class MyNodeBase(bpy.types.ShaderNodeCustomGroup): ... class FooNode(MyNodeBase): bl_idname="my.foo" bl_label = "foo" class BarNode(MyNodeBase): # this get broken if any derved class exists bl_idname="my.bar" bl_label = "bar" class BazNode(BarNode): # this works but breakes BarNode bl_idname="my.baz" bl_label = "baz" ``` Attempt of creating `BarNode` results in: ``` WARN (bpy.rna): /home/sources/buildbot-x86_64-slave/linux_glibc217_x86_64_cmake/blender.git/source/blender/python/intern/bpy_rna.c:8164 bpy_class_call: unable to get Python class for RNA struct 'my.bar' Traceback (most recent call last): File "/home/qmax/Heap/3d/test.blend/nodes.py", line 23, in execute RuntimeError: Error: Cannot add node of type my.bar to node tree 'Shader Nodetree' ``` **Exact steps for others to reproduce the error** - open attached file and execute packed nodes.py - call operator 'add bar' in shader editor [test.blend](https://archive.blender.org/developer/F8161935/test.blend) **Workaround** Register classes in reverse order: derived first, then base. ``` classes = (BazNode, BarNode, FooNode) for c in classes: bpy.utils.register_class(c) ```
Author

Added subscriber: @qwiglydee

Added subscriber: @qwiglydee
Author

The workaround is to register classes in reverse order: first 'baz', and then 'bar'.

This is crazy.

The workaround is to register classes in reverse order: first 'baz', and then 'bar'. This is crazy.
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Confirmed on first sight, checking...

Confirmed on first sight, checking...
Member

Added subscribers: @JacquesLucke, @ideasman42

Added subscribers: @JacquesLucke, @ideasman42
Member

Before digging deeper: @JacquesLucke : this not to be expected, right?
The ptr->type->py_type doesnt seem to be set...

Maybe this rings a bell immediately?

CC @ideasman42

Before digging deeper: @JacquesLucke : this not to be expected, right? The `ptr->type->py_type` doesnt seem to be set... Maybe this rings a bell immediately? CC @ideasman42
Member

Unfortunately, I'm not sure what's going one.
I have a habbit of subclassing all the classes I want to register directly from the bpy.types... base class, instead of having an intermediate super class. Maybe this is why I never had this problem (or the problem is why I have this habbit...).

Unfortunately, I'm not sure what's going one. I have a habbit of subclassing all the classes I want to register directly from the `bpy.types...` base class, instead of having an intermediate super class. Maybe this is why I never had this problem (or the problem is why I have this habbit...).
Member

Added subscriber: @mont29

Added subscriber: @mont29
Member

@mont29: since you were on 627a344635: is this something that fits your current mindset?

@mont29: since you were on 627a344635: is this something that fits your current mindset?

Added subscriber: @PaulMelis

Added subscriber: @PaulMelis
Member

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker
Member

Due to long silence I will set this as a known issue.

Due to long silence I will set this as a known issue.

Added subscriber: @timodriaan

Added subscriber: @timodriaan

Added subscriber: @lvxejay

Added subscriber: @lvxejay
Philipp Oeser removed the
Interest
Nodes & Physics
label 2023-02-10 08:47:09 +01:00
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
7 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#71858
No description provided.