reg
This commit is contained in:
parent
fd89179634
commit
3999d67174
1 changed files with 16 additions and 5 deletions
21
registry.py
21
registry.py
|
|
@ -7,7 +7,8 @@ _timer_registry: list[Callable[..., int | None]] = []
|
||||||
|
|
||||||
# BPY CLASSES
|
# BPY CLASSES
|
||||||
def register_class(cls: type) -> type:
|
def register_class(cls: type) -> type:
|
||||||
_bpy_class_registry.append(cls)
|
if cls not in _bpy_class_registry:
|
||||||
|
_bpy_class_registry.append(cls)
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
def get() -> list[type]:
|
def get() -> list[type]:
|
||||||
|
|
@ -26,12 +27,22 @@ def get_class_by_name(name: str) -> type | None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def blender_register_classes():
|
def blender_register_classes():
|
||||||
for module in get():
|
for cls in _bpy_class_registry:
|
||||||
bpy.utils.register_class(module)
|
try:
|
||||||
|
bpy.utils.register_class(cls)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Nodeslicer: Failed to register {cls}: {e}")
|
||||||
|
|
||||||
def blender_unregister_classes():
|
def blender_unregister_classes():
|
||||||
for module in get():
|
for cls in reversed(_bpy_class_registry):
|
||||||
bpy.utils.unregister_class(module)
|
try:
|
||||||
|
if hasattr(cls, "is_registered") and cls.is_registered: # type: ignore
|
||||||
|
bpy.utils.unregister_class(cls)
|
||||||
|
elif hasattr(cls, "bl_rna"):
|
||||||
|
# Fallback for classes that don't have is_registered (older Blender or certain types)
|
||||||
|
bpy.utils.unregister_class(cls)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Nodeslicer: Failed to unregister {cls}: {e}")
|
||||||
|
|
||||||
# TIMERS
|
# TIMERS
|
||||||
def register_timer(clb: Callable[..., Any]):
|
def register_timer(clb: Callable[..., Any]):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue