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.
Showing only changes of commit 709f0a68ab - Show all commits

View File

@ -5,9 +5,9 @@
bl_info = { bl_info = {
"name": "Edit Operator Source", "name": "Edit Operator Source",
"author": "scorpion81", "author": "scorpion81, L0Lock",
"version": (1, 2, 3), "version": (1, 2, 4),
"blender": (3, 2, 0), "blender": (3, 6, 0),
"location": "Text Editor > Sidebar > Edit Operator", "location": "Text Editor > Sidebar > Edit Operator",
"description": "Opens source file of chosen operator or call locations, if source not available", "description": "Opens source file of chosen operator or call locations, if source not available",
"warning": "", "warning": "",
@ -48,13 +48,19 @@ def make_loc(prefix, c):
return prefix+": " + space + " " + region + " " + label 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): for name, m in inspect.getmembers(mod):
if inspect.ismodule(m): if inspect.ismodule(m):
if m.__name__ not in exclude: if m.__name__ not in exclude:
#print(name, m.__name__) #print(name, m.__name__)
walk_module(opname, m, calls, exclude) walk_module(opname, m, calls, exclude, visited)
elif inspect.isclass(m): elif inspect.isclass(m):
if (issubclass(m, Panel) or \ if (issubclass(m, Panel) or \
issubclass(m, Header) or \ issubclass(m, Header) or \
@ -217,12 +223,12 @@ class TEXT_OT_EditOperator(Operator):
exclude.append("sys") exclude.append("sys")
calls = [] 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(): for m in addon_utils.modules():
try: try:
mod = sys.modules[m.__name__] mod = sys.modules[m.__name__]
walk_module(self.op, mod, calls, exclude) walk_module(self.op, mod, calls, exclude, visited=set())
except KeyError: except KeyError:
continue continue
@ -275,7 +281,7 @@ class TEXT_PT_EditOperatorPanel(Panel):
bl_space_type = 'TEXT_EDITOR' bl_space_type = 'TEXT_EDITOR'
bl_region_type = 'UI' bl_region_type = 'UI'
bl_label = "Edit Operator" bl_label = "Edit Operator"
bl_category = "Text" bl_category = "Dev"
bl_options = {'DEFAULT_CLOSED'} bl_options = {'DEFAULT_CLOSED'}
def draw(self, context): def draw(self, context):