Page MenuHome

Inharitance for `ShaderNodeCustomGroup` is broken
Open, Confirmed, MediumPublic

Description

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: rB26bd5ebd42e3
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

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

Details

Type
Bug

Event Timeline

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

This is crazy.

Philipp Oeser (lichtwerk) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.Mon, Nov 25, 1:27 PM

Confirmed on first sight, checking...

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

Maybe this rings a bell immediately?

CC @Campbell Barton (campbellbarton)

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...).