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`
This commit is contained in:
@@ -144,6 +144,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
|
|||||||
:type refresh_scripts: bool
|
:type refresh_scripts: bool
|
||||||
"""
|
"""
|
||||||
use_time = _bpy.app.debug_python
|
use_time = _bpy.app.debug_python
|
||||||
|
use_class_register_check = use_time
|
||||||
|
|
||||||
if use_time:
|
if use_time:
|
||||||
import time
|
import time
|
||||||
@@ -276,6 +277,16 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
|
|||||||
if use_time:
|
if use_time:
|
||||||
print("Python Script Load Time %.4f" % (time.time() - t_main))
|
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
|
# base scripts
|
||||||
_scripts = _os.path.join(_os.path.dirname(__file__),
|
_scripts = _os.path.join(_os.path.dirname(__file__),
|
||||||
|
Reference in New Issue
Block a user