[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54835] trunk/blender/release/scripts/ startup/bl_operators/wm.py: fix for python exception getting the ID from an operator button:
Campbell Barton
ideasman42 at gmail.com
Mon Feb 25 05:19:28 CET 2013
Revision: 54835
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54835
Author: campbellbarton
Date: 2013-02-25 04:19:28 +0000 (Mon, 25 Feb 2013)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_operators/wm.py
Modified: trunk/blender/release/scripts/startup/bl_operators/wm.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/wm.py 2013-02-25 03:54:16 UTC (rev 54834)
+++ trunk/blender/release/scripts/startup/bl_operators/wm.py 2013-02-25 04:19:28 UTC (rev 54835)
@@ -820,25 +820,42 @@
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
More information about the Bf-blender-cvs
mailing list