[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25752] trunk/blender/source/blender: Python descriptions were not getting used in tooltips.
Campbell Barton
ideasman42 at gmail.com
Tue Jan 5 21:19:54 CET 2010
Revision: 25752
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25752
Author: campbellbarton
Date: 2010-01-05 21:19:54 +0100 (Tue, 05 Jan 2010)
Log Message:
-----------
Python descriptions were not getting used in tooltips.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_wm.c
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_wm.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_wm.c 2010-01-05 20:18:45 UTC (rev 25751)
+++ trunk/blender/source/blender/makesrna/intern/rna_wm.c 2010-01-05 20:19:54 UTC (rev 25752)
@@ -881,6 +881,11 @@
RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */
RNA_def_property_flag(prop, PROP_REGISTER);
+ prop= RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "type->description");
+ RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */
+ RNA_def_property_flag(prop, PROP_REGISTER);
+
prop= RNA_def_property(srna, "bl_register", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "type->flag", OPTYPE_REGISTER);
RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2010-01-05 20:18:45 UTC (rev 25751)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2010-01-05 20:19:54 UTC (rev 25752)
@@ -4119,31 +4119,26 @@
item = PyObject_GetAttrString(py_class, identifier);
if (item==NULL) {
-
/* Sneaky workaround to use the class name as the bl_idname */
- if(strcmp(identifier, "bl_idname") == 0) {
- item= PyObject_GetAttrString(py_class, "__name__");
- if(item) {
- Py_DECREF(item); /* no need to keep a ref, the class owns it */
+#define BPY_REPLACEMENT_STRING(rna_attr, py_attr) \
+ if(strcmp(identifier, rna_attr) == 0) { \
+ item= PyObject_GetAttrString(py_class, py_attr); \
+ if(item && item != Py_None) { \
+ if(pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class error:") != 0) { \
+ Py_DECREF(item); \
+ return -1; \
+ } \
+ } \
+ Py_XDECREF(item); \
+ } \
- if(pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class error:") != 0)
- return -1;
- }
- }
-#if 0
- if(strcmp(identifier, "bl_label") == 0) {
- item= PyObject_GetAttrString(py_class, "__doc__");
+ BPY_REPLACEMENT_STRING("bl_idname", "__name__");
+ BPY_REPLACEMENT_STRING("bl_description", "__doc__");
- if(item) {
- Py_DECREF(item); /* no need to keep a ref, the class owns it */
+#undef BPY_REPLACEMENT_STRING
- if(pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class error:") != 0)
- return -1;
- }
- }
-#endif
if (item == NULL && (((flag & PROP_REGISTER_OPTIONAL) != PROP_REGISTER_OPTIONAL))) {
PyErr_Format( PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, identifier);
return -1;
More information about the Bf-blender-cvs
mailing list