Merge with 2.5 -r 21619:21756.
[blender.git] / source / blender / python / intern / bpy_rna.c
index bebb745a27eb7789e1f7877ed73f9bb9998bf716..c7767c6c08e34b0cbac6f92a6847a2dfedb81dab 100644 (file)
@@ -44,6 +44,8 @@
 #include "DNA_scene_types.h"
 #include "ED_keyframing.h"
 
+#include "rna_internal_types.h"        /* PropertyRNA */
+
 #define USE_MATHUTILS
 
 #ifdef USE_MATHUTILS
@@ -1324,6 +1326,7 @@ static int pyrna_struct_setattro( BPy_StructRNA * self, PyObject *pyname, PyObje
 {
        char *name = _PyUnicode_AsString(pyname);
        PropertyRNA *prop = RNA_struct_find_property(&self->ptr, name);
+       int ret;
        
        if (prop==NULL) {
                if (!BPy_StructRNA_CheckExact(self) && PyObject_GenericSetAttr((PyObject *)self, pyname, value) >= 0) {
@@ -1341,7 +1344,11 @@ static int pyrna_struct_setattro( BPy_StructRNA * self, PyObject *pyname, PyObje
        }
                
        /* pyrna_py_to_prop sets its own exceptions */
-       return pyrna_py_to_prop(&self->ptr, prop, NULL, value);
+       ret= pyrna_py_to_prop(&self->ptr, prop, NULL, value);
+       
+       RNA_property_update(BPy_GetContext(), &self->ptr, prop);
+
+       return ret;
 }
 
 static PyObject *pyrna_prop_keys(BPy_PropertyRNA *self)
@@ -1800,6 +1807,10 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
                /* resolve the array from a new pytype */
                ret = PyTuple_New(len);
 
+               /* for return values, data is a pointer to an array, not first element pointer */
+               if (prop->flag & PROP_DYNAMIC_ARRAY)
+                       data = *((char**)data);
+
                switch (type) {
                case PROP_BOOLEAN:
                        for(a=0; a<len; a++)
@@ -1867,8 +1878,12 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
                                newptr= *(PointerRNA*)data;
                        }
                        else {
-                               /* XXX this is missing the ID part! */
-                               RNA_pointer_create(NULL, type, *(void**)data, &newptr);
+                               if (RNA_struct_is_ID(type)) {
+                                       RNA_id_pointer_create(*(void**)data, &newptr);
+                               }
+                               else {
+                                       RNA_pointer_create(NULL, type, *(void**)data, &newptr);
+                               }
                        }
 
                        if (newptr.data) {