diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-02-25 08:19:28 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-02-25 08:19:28 +0400 |
commit | 732f6f7bd0b70777b5807727d36df4a956dfe9f3 (patch) | |
tree | 1c414c66184f3110cb3f906b480ff352cbd5a9dd /release/scripts/startup/bl_operators/wm.py | |
parent | 63feb31b354e87750f44549a2e88bbb3570e3e73 (diff) |
fix for python exception getting the ID from an operator button:
attempting to select 'Online Manual' or 'Python Reference' from the UI of a running operator would give an error popup.
Diffstat (limited to 'release/scripts/startup/bl_operators/wm.py')
-rw-r--r-- | release/scripts/startup/bl_operators/wm.py | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 6ac61a9f5e7..b2f094e7ccc 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -820,25 +820,42 @@ def _wm_doc_get_id(doc_id, do_url=True, url_prefix=""): elif len(id_split) == 2: # rna, class.prop class_name, class_prop = id_split + # an operator (common case - just button referencing an op) if hasattr(bpy.types, class_name.upper() + "_OT_" + class_prop): if do_url: url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" % (url_prefix, class_name, class_name, class_prop)) else: rna = "bpy.ops.%s.%s" % (class_name, class_prop) else: + rna_class = getattr(bpy.types, class_name) + + # an operator setting (selected from a running operator), rare case + # note: Py defined operators are subclass of Operator, + # C defined operators are subclass of OperatorProperties. + # we may need to check on this at some point. + if issubclass(rna_class, (bpy.types.Operator, bpy.types.OperatorProperties)): + # note: ignore the prop name since we don't have a way to link into it + class_name, class_prop = class_name.split("_OT_", 1) + class_name = class_name.lower() + if do_url: + url = ("%s/bpy.ops.%s.html#bpy.ops.%s.%s" % (url_prefix, class_name, class_name, class_prop)) + else: + rna = "bpy.ops.%s.%s" % (class_name, class_prop) + else: + # an RNA setting, common case - # detect if this is a inherited member and use that name instead - rna_parent = getattr(bpy.types, class_name).bl_rna - rna_prop = rna_parent.properties[class_prop] - rna_parent = rna_parent.base - while rna_parent and rna_prop == rna_parent.properties.get(class_prop): - class_name = rna_parent.identifier + # detect if this is a inherited member and use that name instead + rna_parent = rna_class.bl_rna + rna_prop = rna_parent.properties[class_prop] rna_parent = rna_parent.base + while rna_parent and rna_prop == rna_parent.properties.get(class_prop): + class_name = rna_parent.identifier + rna_parent = rna_parent.base - if do_url: - url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" % (url_prefix, class_name, class_name, class_prop)) - else: - rna = ("bpy.types.%s.%s" % (class_name, class_prop)) + if do_url: + url = ("%s/bpy.types.%s.html#bpy.types.%s.%s" % (url_prefix, class_name, class_name, class_prop)) + else: + rna = ("bpy.types.%s.%s" % (class_name, class_prop)) return url if do_url else rna |