Page MenuHome

You can't register a `GizmoGroup` after unregistering it
Open, Confirmed, MediumPublic

Description

System Information
Operating system: windows 64bits

Blender Version
Broken:
blender2.8, 2019-02-10

Short description of error
When trying to unregister and then register an addon that supports GizmoGroups. An error message is displayed and the process stops.

Exact steps for others to reproduce the error
In the gizmo_simple.py template, add these lines:

issubclass(MyLightWidgetGroup, bpy.types.GizmoGroup)

bpy.utils.unregister_class(MyLightWidgetGroup)
bpy.utils.register_class(MyLightWidgetGroup)

When trying to execute the code through Blender, you should see the error message :

Traceback (most recent call last):
  File "\gizmo_simple.py", line 52, in <module>

TypeError: expected GizmoGroup subclass of class "MyLightWidgetGroup"
Error: Python script fail, look in the console for now...

Details

Type
Bug

Event Timeline

Jacques Lucke (JacquesLucke) triaged this task as Confirmed, Medium priority.Feb 11 2019, 11:52 AM

It's interesting that this error is related to issubclass(MyLightWidgetGroup, bpy.types.GizmoGroup). When I remove this line, it works just fine.

Here is a solution I did to avoid this error.
But it looks kind of hachy.

diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index 32e8fe40c6a..f105c2980f8 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -646,6 +646,12 @@ class Gizmo(StructRNA):
         return (batch, shader)
 
 
+# Dummy class to keep the reference in `bpy_types_dict` and avoid
+# erros like: "TypeError: expected GizmoGroup subclass of class ..."
+class GizmoGroup(StructRNA):
+    __slots__ = ()
+
+
 # Only defined so operators members can be used by accessing self.order
 # with doc generation 'self.properties.bl_rna.properties' can fail
 class Operator(StructRNA, metaclass=RNAMeta):

(It would be nice if it could be fixed soon)