Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/editors/interface/interface.c4
-rw-r--r--source/blender/editors/object/object_add.c1
-rw-r--r--source/blender/makesrna/intern/rna_access.c47
-rw-r--r--source/blender/python/intern/bpy_rna.c36
4 files changed, 56 insertions, 32 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 4c86b9480d4..d1c65fb333c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2528,8 +2528,10 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1,
}
}
}
- else
+ else {
+ printf("ui_def_but_rna: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
str= (char*)propname;
+ }
/* now create button */
but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, NULL, min, max, a1, a2, tip);
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index d3debc84bdd..a847296e509 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -501,7 +501,6 @@ static EnumPropertyItem prop_metaball_types[]= {
static int object_metaball_add_exec(bContext *C, wmOperator *op)
{
Object *obedit= CTX_data_edit_object(C);
- MetaBall *mball;
MetaElem *elem;
int newob= 0;
int enter_editmode;
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 73af75ca960..cdb032b54af 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -2949,7 +2949,7 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr,
PropertyRNA *prop;
PointerRNA curptr, nextptr;
char fixedbuf[256], *token;
- int type, len, intkey;
+ int type, intkey;
prop= NULL;
curptr= *ptr;
@@ -3001,33 +3001,44 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr,
break;
case PROP_COLLECTION:
if(*path) {
- /* resolve the lookup with [] brackets */
- token= rna_path_token(&path, fixedbuf, sizeof(fixedbuf), 1);
-
- if(!token)
- return 0;
-
- len= strlen(token);
+ if(*path == '[') {
+ /* resolve the lookup with [] brackets */
+ token= rna_path_token(&path, fixedbuf, sizeof(fixedbuf), 1);
+
+ if(!token)
+ return 0;
+
+ /* check for "" to see if it is a string */
+ if(rna_token_strip_quotes(token)) {
+ RNA_property_collection_lookup_string(&curptr, prop, token+1, &nextptr);
+ }
+ else {
+ /* otherwise do int lookup */
+ intkey= atoi(token);
+ RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr);
+ }
- /* check for "" to see if it is a string */
- if(rna_token_strip_quotes(token)) {
- RNA_property_collection_lookup_string(&curptr, prop, token+1, &nextptr);
+ if(token != fixedbuf) {
+ MEM_freeN(token);
+ }
}
else {
- /* otherwise do int lookup */
- intkey= atoi(token);
- RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr);
- }
+ PointerRNA c_ptr;
+
+ /* ensure we quit on invalid values */
+ nextptr.data = NULL;
- if(token != fixedbuf)
- MEM_freeN(token);
+ if(RNA_property_collection_type_get(&curptr, prop, &c_ptr)) {
+ nextptr= c_ptr;
+ }
+ }
if(nextptr.data)
curptr= nextptr;
else
return 0;
}
-
+
break;
default:
if (index==NULL)
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 07b237a40f8..834254a495d 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -2142,25 +2142,37 @@ static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *
}
static char pyrna_struct_path_resolve_doc[] =
-".. method:: path_resolve(path)\n"
+".. method:: path_resolve(path, coerce=True)\n"
"\n"
-" Returns the property from the path given or None if the property is not found.";
+" Returns the property from the path, raise an exception when not found.\n"
+"\n"
+" :arg path: path which this property resolves.\n"
+" :type path: string\n"
+" :arg coerce: optional argument, when True, the property will be converted into its python representation.\n"
+" :type coerce: boolean\n";
-static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *value)
+static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
{
- char *path= _PyUnicode_AsString(value);
+ char *path;
+ PyObject *coerce= Py_True;
PointerRNA r_ptr;
PropertyRNA *r_prop;
- if(path==NULL) {
- PyErr_SetString(PyExc_TypeError, "bpy_struct.path_resolve(): accepts only a single string argument");
+ if (!PyArg_ParseTuple(args, "s|O!:path_resolve", &path, &PyBool_Type, &coerce))
return NULL;
- }
-
- if (RNA_path_resolve(&self->ptr, path, &r_ptr, &r_prop))
- return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
- Py_RETURN_NONE;
+ if (RNA_path_resolve(&self->ptr, path, &r_ptr, &r_prop)) {
+ if(coerce == Py_False) {
+ return pyrna_prop_CreatePyObject(&r_ptr, r_prop);
+ }
+ else {
+ return pyrna_prop_to_py(&r_ptr, r_prop);
+ }
+ }
+ else {
+ PyErr_Format(PyExc_TypeError, "%.200s.path_resolve(\"%.200s\") could not be resolved", RNA_struct_identifier(self->ptr.type), path);
+ return NULL;
+ }
}
static char pyrna_struct_path_from_id_doc[] =
@@ -3112,7 +3124,7 @@ static struct PyMethodDef pyrna_struct_methods[] = {
{"driver_remove", (PyCFunction)pyrna_struct_driver_remove, METH_VARARGS, pyrna_struct_driver_remove_doc},
{"is_property_set", (PyCFunction)pyrna_struct_is_property_set, METH_VARARGS, pyrna_struct_is_property_set_doc},
{"is_property_hidden", (PyCFunction)pyrna_struct_is_property_hidden, METH_VARARGS, pyrna_struct_is_property_hidden_doc},
- {"path_resolve", (PyCFunction)pyrna_struct_path_resolve, METH_O, pyrna_struct_path_resolve_doc},
+ {"path_resolve", (PyCFunction)pyrna_struct_path_resolve, METH_VARARGS, pyrna_struct_path_resolve_doc},
{"path_from_id", (PyCFunction)pyrna_struct_path_from_id, METH_VARARGS, pyrna_struct_path_from_id_doc},
{"recast_type", (PyCFunction)pyrna_struct_recast_type, METH_NOARGS, pyrna_struct_recast_type_doc},
{"__dir__", (PyCFunction)pyrna_struct_dir, METH_NOARGS, NULL},