Fix #104725: Edit source operator recursion error when used #104730

Open
Loïc DAUTRY wants to merge 1 commits from L0Lock/blender-addons:l0lock-patch-1 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

View File

@ -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):