From 709f0a68ab6ceb52676596099d1b00017dbf5734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20DAUTRY?= Date: Sun, 2 Jul 2023 01:01:09 +0200 Subject: [PATCH] Edit Operator Source: patch for #104725 and minor UI tweak Edit Operator Source: - added a check for visited modules in walk_module() to avoid recursion as in issue #104725 - changed the sidebar tab to "Dev", as per other developers addons like Icon Viewer. --- development_edit_operator.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/development_edit_operator.py b/development_edit_operator.py index 0eeeeec15..3168b6d3f 100644 --- a/development_edit_operator.py +++ b/development_edit_operator.py @@ -5,9 +5,9 @@ bl_info = { "name": "Edit Operator Source", - "author": "scorpion81", - "version": (1, 2, 3), - "blender": (3, 2, 0), + "author": "scorpion81, L0Lock", + "version": (1, 2, 4), + "blender": (3, 6, 0), "location": "Text Editor > Sidebar > Edit Operator", "description": "Opens source file of chosen operator or call locations, if source not available", "warning": "", @@ -48,13 +48,19 @@ def make_loc(prefix, c): return prefix+": " + space + " " + region + " " + label -def walk_module(opname, mod, calls=[], exclude=[]): +def walk_module(opname, mod, calls=[], exclude=[], visited=None): + if visited is None: + visited = set() + + if mod in visited: + return + visited.add(mod) for name, m in inspect.getmembers(mod): if inspect.ismodule(m): if m.__name__ not in exclude: #print(name, m.__name__) - walk_module(opname, m, calls, exclude) + walk_module(opname, m, calls, exclude, visited) elif inspect.isclass(m): if (issubclass(m, Panel) or \ issubclass(m, Header) or \ @@ -217,12 +223,12 @@ class TEXT_OT_EditOperator(Operator): exclude.append("sys") calls = [] - walk_module(self.op, bl_ui, calls, exclude) + walk_module(self.op, bl_ui, calls, exclude, visited=set()) for m in addon_utils.modules(): try: mod = sys.modules[m.__name__] - walk_module(self.op, mod, calls, exclude) + walk_module(self.op, mod, calls, exclude, visited=set()) except KeyError: continue @@ -275,7 +281,7 @@ class TEXT_PT_EditOperatorPanel(Panel): bl_space_type = 'TEXT_EDITOR' bl_region_type = 'UI' bl_label = "Edit Operator" - bl_category = "Text" + bl_category = "Dev" bl_options = {'DEFAULT_CLOSED'} def draw(self, context): -- 2.30.2