patch from Martin, call classes register/unregister functions.

Modified to only do one lookup.

from Martin: 
 "Basically, what it does is allow you to add register and unregister class methods to rna types, this way you don't have to rely on module register/unregister methods to setup your types properly (and it makes them easier to move around when reorganizing code and easier to understand what a type does when reading code). This is especially nice for PropertyGroup classes that are added as properties to existing types, you can easily see in their register methods where they are added and removed in their unregister method. Obviously, those two methods are optional, so current code still works fine."
This commit is contained in:
2011-03-21 06:22:09 +00:00
parent 6031744c35
commit 599bd1cbda

View File

@@ -436,6 +436,9 @@ def register_module(module, verbose=False):
print(" %r" % cls)
try:
register_class(cls)
cls_func = getattr(cls, "register", None)
if cls_func is not None:
cls_func()
except:
print("bpy.utils.register_module(): failed to registering class %r" % cls)
print("\t", path, "line", line)
@@ -455,6 +458,9 @@ def unregister_module(module, verbose=False):
print(" %r" % cls)
try:
unregister_class(cls)
cls_func = getattr(cls, "unregister", None)
if cls_func is not None:
cls_func()
except:
print("bpy.utils.unregister_module(): failed to unregistering class %r" % cls)
print("\t", path, "line", line)