RNA Bugfix: (Brecht, please check over these fixes...)
authorJoshua Leung <aligorith@gmail.com>
Mon, 11 May 2009 02:07:40 +0000 (02:07 +0000)
committerJoshua Leung <aligorith@gmail.com>
Mon, 11 May 2009 02:07:40 +0000 (02:07 +0000)
Fixed one of the causes of keyframes not being able to be inserted. For ID-types where inheritence of the basic wrapping of the struct (i.e. for Lamp blocks, shadow and other lamp-type specific settings were only defined in subclasses of the Lamp struct), the RNA_id_pointer_create() function now performs additional refinement of the PointerRNA so that the pointer will be resolved correctly to allow access to these settings.

The other case which is unresolved for now is nestled structs. The RNA_path_from_ID_to_property() needs modification for this, but dunno how yet.

source/blender/editors/animation/keyframing.c
source/blender/makesrna/intern/rna_access.c

index b09cc3b78e196135849fcf605517cac676e2cc83..f7a16f63691163ae957831ab7581ba059e6d09d4 100644 (file)
@@ -68,6 +68,7 @@ bAction *verify_adt_action (ID *id, short add)
                adt= BKE_id_add_animdata(id);
        if (adt == NULL) { 
                /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */
+               printf("ERROR: Couldn't add AnimData (ID = %s) \n", (id) ? (id->name) : "<None>");
                return NULL;
        }
                
@@ -793,6 +794,9 @@ short insert_keyframe (ID *id, bAction *act, const char group[], const char rna_
                }
        }
        
+       /* no F-Curve to add keyframes to */
+       printf("ERROR: no F-Curve to add keyframes to \n");
+       
        /* return failure */
        return 0;
 }
@@ -1203,11 +1207,11 @@ static int insert_key_button_exec (bContext *C, wmOperator *op)
        memset(&ptr, 0, sizeof(PointerRNA));
        uiAnimContextProperty(C, &ptr, &prop, &index);
        
-       if(ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
+       if ((ptr.data && prop) && RNA_property_animateable(&ptr, prop)) {
                path= RNA_path_from_ID_to_property(&ptr, prop);
                
-               if(path) {
-                       if(all) {
+               if (path) {
+                       if (all) {
                                length= RNA_property_array_length(prop);
                                
                                if(length) index= 0;
@@ -1216,14 +1220,20 @@ static int insert_key_button_exec (bContext *C, wmOperator *op)
                        else
                                length= 1;
                        
-                       for(a=0; a<length; a++)
+                       for (a=0; a<length; a++)
                                success+= insert_keyframe(ptr.id.data, NULL, NULL, path, index+a, cfra, 0);
                        
                        MEM_freeN(path);
                }
+               else if (G.f & G_DEBUG)
+                       printf("Button Insert-Key: no path to property \n");
+       }
+       else if (G.f & G_DEBUG) {
+               printf("ptr.data = %p, prop = %p,", ptr.data, prop);
+               printf("animateable = %d \n", RNA_property_animateable(&ptr, prop));
        }
        
-       if(success) {
+       if (success) {
                /* send updates */
                ED_anim_dag_flush_update(C);    
                
@@ -1267,11 +1277,11 @@ static int delete_key_button_exec (bContext *C, wmOperator *op)
        memset(&ptr, 0, sizeof(PointerRNA));
        uiAnimContextProperty(C, &ptr, &prop, &index);
 
-       if(ptr.data && prop) {
+       if (ptr.data && prop) {
                path= RNA_path_from_ID_to_property(&ptr, prop);
                
-               if(path) {
-                       if(all) {
+               if (path) {
+                       if (all) {
                                length= RNA_property_array_length(prop);
                                
                                if(length) index= 0;
@@ -1280,11 +1290,16 @@ static int delete_key_button_exec (bContext *C, wmOperator *op)
                        else
                                length= 1;
                        
-                       for(a=0; a<length; a++)
+                       for (a=0; a<length; a++)
                                success+= delete_keyframe(ptr.id.data, NULL, NULL, path, index+a, cfra, 0);
                        
                        MEM_freeN(path);
                }
+               else if (G.f & G_DEBUG)
+                       printf("Button Delete-Key: no path to property \n");
+       }
+       else if (G.f & G_DEBUG) {
+               printf("ptr.data = %p, prop = %p \n", ptr.data, prop);
        }
        
        
index 5532ab90e4293fc01ba955f95dbdfdba9f0af2f8..4d2302f1c067d3da9388a46e292039923a76f93b 100644 (file)
@@ -69,8 +69,11 @@ void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
                memset(&tmp, 0, sizeof(tmp));
                tmp.data= id;
                idtype= rna_ID_refine(&tmp);
+               
+               if(idtype->refine)
+                       idtype= idtype->refine(&tmp);
        }
-
+       
        r_ptr->id.data= id;
        r_ptr->type= idtype;
        r_ptr->data= id;
@@ -2533,9 +2536,9 @@ int RNA_function_call_direct_va(PointerRNA *ptr, FunctionRNA *func, const char *
        PropertyRNA *pret, *parm;
        PropertyType type;
        int i, ofs, flen, flag, len, alen, err= 0;
-       const char *tid, *fid, *pid;
+       const char *tid, *fid, *pid=NULL;
        char ftype;
-       void **retdata;
+       void **retdata=NULL;
 
        RNA_pointer_create(NULL, &RNA_Function, func, &funcptr);