Bugfix #20752: Background Image Panel Properties Keyframing?

Added a check in RNA_property_animateable() which checks if the base ID-block can have animation data or not. Screen data currently cannot have animation data, so this solves that problem (where there were non-functional entries there in the menu).
This commit is contained in:
Joshua Leung 2010-01-27 10:43:14 +00:00
parent f268ab1eba
commit 2cb23d03ef
3 changed files with 14 additions and 6 deletions

@ -43,7 +43,10 @@ struct AnimMapper;
/* ************************************* */ /* ************************************* */
/* AnimData API */ /* AnimData API */
/* Get AnimData from the given ID-block. */ /* Check if the given ID-block can have AnimData */
short id_type_can_have_animdata(struct ID *id);
/* Get AnimData from the given ID-block */
struct AnimData *BKE_animdata_from_id(struct ID *id); struct AnimData *BKE_animdata_from_id(struct ID *id);
/* Add AnimData to the given ID-block */ /* Add AnimData to the given ID-block */

@ -60,8 +60,8 @@
/* Getter/Setter -------------------------------------------- */ /* Getter/Setter -------------------------------------------- */
/* Internal utility to check if ID can have AnimData */ /* Check if ID can have AnimData */
static short id_has_animdata (ID *id) short id_type_can_have_animdata (ID *id)
{ {
/* sanity check */ /* sanity check */
if (id == NULL) if (id == NULL)
@ -99,7 +99,7 @@ AnimData *BKE_animdata_from_id (ID *id)
* types that do to be of type IdAdtTemplate, and extract the * types that do to be of type IdAdtTemplate, and extract the
* AnimData that way * AnimData that way
*/ */
if (id_has_animdata(id)) { if (id_type_can_have_animdata(id)) {
IdAdtTemplate *iat= (IdAdtTemplate *)id; IdAdtTemplate *iat= (IdAdtTemplate *)id;
return iat->adt; return iat->adt;
} }
@ -117,7 +117,7 @@ AnimData *BKE_id_add_animdata (ID *id)
* types that do to be of type IdAdtTemplate, and add the AnimData * types that do to be of type IdAdtTemplate, and add the AnimData
* to it using the template * to it using the template
*/ */
if (id_has_animdata(id)) { if (id_type_can_have_animdata(id)) {
IdAdtTemplate *iat= (IdAdtTemplate *)id; IdAdtTemplate *iat= (IdAdtTemplate *)id;
/* check if there's already AnimData, in which case, don't add */ /* check if there's already AnimData, in which case, don't add */
@ -145,7 +145,7 @@ void BKE_free_animdata (ID *id)
/* Only some ID-blocks have this info for now, so we cast the /* Only some ID-blocks have this info for now, so we cast the
* types that do to be of type IdAdtTemplate * types that do to be of type IdAdtTemplate
*/ */
if (id_has_animdata(id)) { if (id_type_can_have_animdata(id)) {
IdAdtTemplate *iat= (IdAdtTemplate *)id; IdAdtTemplate *iat= (IdAdtTemplate *)id;
AnimData *adt= iat->adt; AnimData *adt= iat->adt;

@ -36,6 +36,7 @@
#include "BLI_dynstr.h" #include "BLI_dynstr.h"
#include "BLI_ghash.h" #include "BLI_ghash.h"
#include "BKE_animsys.h"
#include "BKE_context.h" #include "BKE_context.h"
#include "BKE_idprop.h" #include "BKE_idprop.h"
#include "BKE_main.h" #include "BKE_main.h"
@ -1110,6 +1111,10 @@ int RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index)
int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop) int RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop)
{ {
/* check that base ID-block can support animation data */
if (!id_type_can_have_animdata(ptr->id.data))
return 0;
prop= rna_ensure_property(prop); prop= rna_ensure_property(prop);
if(!(prop->flag & PROP_ANIMATEABLE)) if(!(prop->flag & PROP_ANIMATEABLE))