From 2f4f046b6f16d4429b6d74270945cbb87cca6c52 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 11 Feb 2011 01:12:01 +0000 Subject: UI functions added to existing UI classes (operators adding their own menus for eg), 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 | 17 ++++++++++++++--- release/scripts/modules/bpy_types.py | 7 ++++++- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'release') diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index a86cfacb56b..1bb62fdb29f 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -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 diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index fcc3166b066..4eb712a65cc 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -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 -- cgit v1.2.3