UI functions added to existing UI classes (operators adding their own menus for eg),
authorCampbell Barton <ideasman42@gmail.com>
Fri, 11 Feb 2011 01:12:01 +0000 (01:12 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 11 Feb 2011 01:12:01 +0000 (01:12 +0000)
would stop the entire menu from drawing if they raised an exception.

now print the exception and continue.

Also added a verbose argument for bpy.utils.(un)register_module() to help test whats being registered.

release/scripts/modules/bpy/utils.py
release/scripts/modules/bpy_types.py

index a86cfacb56bdf72212e013aca5b82cd20570765a..1bb62fdb29fa7b674946f2f5bf34338db8cbd0f8 100644 (file)
@@ -593,26 +593,37 @@ def _bpy_module_classes(module, is_registered=False):
             i += 1
 
 
-def register_module(module):
+def register_module(module, verbose=False):
     import traceback
+    if verbose:
+        print("bpy.utils.register_module(%r): ..." % module)
     for cls, path, line in _bpy_module_classes(module, is_registered=False):
+        if verbose:
+            print("    %s of %s:%s" % (cls, path, line))
         try:
             register_class(cls)
         except:
             print("bpy.utils.register_module(): failed to registering class '%s.%s'" % (cls.__module__, cls.__name__))
             print("\t", path, "line", line)
             traceback.print_exc()
-
+    if verbose:
+        print("done.\n")
     if "cls" not in locals():
         raise Exception("register_module(%r): defines no classes" % module)
 
 
-def unregister_module(module):
+def unregister_module(module, verbose=False):
     import traceback
+    if verbose:
+        print("bpy.utils.unregister_module(%r): ..." % module)
     for cls, path, line in _bpy_module_classes(module, is_registered=True):
+        if verbose:
+            print("    %s of %s:%s" % (cls, path, line))
         try:
             unregister_class(cls)
         except:
             print("bpy.utils.unregister_module(): failed to unregistering class '%s.%s'" % (cls.__module__, cls.__name__))
             print("\t", path, "line", line)
             traceback.print_exc()
+    if verbose:
+        print("done.\n")
\ No newline at end of file
index fcc3166b066645888e4301c89f8e899d5799d10b..4eb712a65ccc59d467a463f5fb941542ed8bd9d0 100644 (file)
@@ -657,7 +657,12 @@ class _GenericUI:
 
             def draw_ls(self, context):
                 for func in draw_ls._draw_funcs:
-                    func(self, context)
+                    # so bad menu functions dont stop the entire menu from drawing.
+                    try:
+                        func(self, context)
+                    except:
+                        import traceback
+                        traceback.print_exc()
 
             draw_funcs = draw_ls._draw_funcs = [cls.draw]
             cls.draw = draw_ls