RNA Bugfix: (Brecht, please check over these fixes...)

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.
This commit is contained in:
Joshua Leung
2009-05-11 02:07:40 +00:00
parent c32a3bd73b
commit 5c96cd0319
2 changed files with 30 additions and 12 deletions

View 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);
}

View 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);