[Bf-blender-cvs] [f8e02c75ba] master: PyAPI: debug-python check for missing class register

Campbell Barton noreply at git.blender.org
Sun Mar 26 01:31:42 CET 2017


Commit: f8e02c75bad7cd57f3ecda3270cd3775d7c1c7ea
Author: Campbell Barton
Date:   Sun Mar 26 11:14:47 2017 +1100
Branches: master
https://developer.blender.org/rBf8e02c75bad7cd57f3ecda3270cd3775d7c1c7ea

PyAPI: debug-python check for missing class register

Moving to manual class registration means its easier to accidentally
miss registering classes.

Now detect missing class registration
and warn when running with `--debug-python`

===================================================================

M	release/scripts/modules/bpy/utils/__init__.py

===================================================================

diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py
index 65a2f27846..14510c844a 100644
--- a/release/scripts/modules/bpy/utils/__init__.py
+++ b/release/scripts/modules/bpy/utils/__init__.py
@@ -144,6 +144,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
     :type refresh_scripts: bool
     """
     use_time = _bpy.app.debug_python
+    use_class_register_check = use_time
 
     if use_time:
         import time
@@ -276,6 +277,16 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
     if use_time:
         print("Python Script Load Time %.4f" % (time.time() - t_main))
 
+    if use_class_register_check:
+        for cls in _bpy.types.bpy_struct.__subclasses__():
+            if getattr(cls, "is_registered", False):
+                for subcls in cls.__subclasses__():
+                    if not subcls.is_registered:
+                        print(
+                            "Warning, unregistered class: %s(%s)" %
+                            (subcls.__name__, cls.__name__)
+                        )
+
 
 # base scripts
 _scripts = _os.path.join(_os.path.dirname(__file__),




More information about the Bf-blender-cvs mailing list