replace RNA_property_array_length with RNA_property_array_check where the length of the array is only used to check if the property is an array or not.

(this isnt reliable since arrays can be zero length).
This commit is contained in:
2013-09-16 01:35:52 +00:00
parent 7e2977b051
commit abb37f4152
6 changed files with 16 additions and 16 deletions

View File

@@ -1652,19 +1652,19 @@ static void nlaevalchan_value_init(NlaEvalChannel *nec)
*/
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(ptr, prop))
if (RNA_property_array_check(prop))
nec->value = (float)RNA_property_boolean_get_default_index(ptr, prop, index);
else
nec->value = (float)RNA_property_boolean_get_default(ptr, prop);
break;
case PROP_INT:
if (RNA_property_array_length(ptr, prop))
if (RNA_property_array_check(prop))
nec->value = (float)RNA_property_int_get_default_index(ptr, prop, index);
else
nec->value = (float)RNA_property_int_get_default(ptr, prop);
break;
case PROP_FLOAT:
if (RNA_property_array_length(ptr, prop))
if (RNA_property_array_check(prop))
nec->value = RNA_property_float_get_default_index(ptr, prop, index);
else
nec->value = RNA_property_float_get_default(ptr, prop);
@@ -2071,19 +2071,19 @@ void nladata_flush_channels(ListBase *channels)
/* write values - see animsys_write_rna_setting() to sync the code */
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(ptr, prop))
if (RNA_property_array_check(prop))
RNA_property_boolean_set_index(ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
else
RNA_property_boolean_set(ptr, prop, ANIMSYS_FLOAT_AS_BOOL(value));
break;
case PROP_INT:
if (RNA_property_array_length(ptr, prop))
if (RNA_property_array_check(prop))
RNA_property_int_set_index(ptr, prop, array_index, (int)value);
else
RNA_property_int_set(ptr, prop, (int)value);
break;
case PROP_FLOAT:
if (RNA_property_array_length(ptr, prop))
if (RNA_property_array_check(prop))
RNA_property_float_set_index(ptr, prop, array_index, value);
else
RNA_property_float_set(ptr, prop, value);

View File

@@ -132,7 +132,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
propname = RNA_property_ui_name(prop);
/* Array Index - only if applicable */
if (RNA_property_array_length(&ptr, prop)) {
if (RNA_property_array_check(prop)) {
char c = RNA_property_array_item_char(prop, fcu->array_index);
/* we need to write the index to a temp buffer (in py syntax) */

View File

@@ -508,19 +508,19 @@ static float setting_get_rna_value(PointerRNA *ptr, PropertyRNA *prop, int index
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(ptr, prop))
if (RNA_property_array_check(prop))
value = (float)RNA_property_boolean_get_index(ptr, prop, index);
else
value = (float)RNA_property_boolean_get(ptr, prop);
break;
case PROP_INT:
if (RNA_property_array_length(ptr, prop))
if (RNA_property_array_check(prop))
value = (float)RNA_property_int_get_index(ptr, prop, index);
else
value = (float)RNA_property_int_get(ptr, prop);
break;
case PROP_FLOAT:
if (RNA_property_array_length(ptr, prop))
if (RNA_property_array_check(prop))
value = RNA_property_float_get_index(ptr, prop, index);
else
value = RNA_property_float_get(ptr, prop);

View File

@@ -1646,19 +1646,19 @@ void ui_set_but_val(uiBut *but, double value)
if (RNA_property_editable(&but->rnapoin, prop)) {
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(&but->rnapoin, prop))
if (RNA_property_array_check(prop))
RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_boolean_set(&but->rnapoin, prop, value);
break;
case PROP_INT:
if (RNA_property_array_length(&but->rnapoin, prop))
if (RNA_property_array_check(prop))
RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, (int)value);
else
RNA_property_int_set(&but->rnapoin, prop, (int)value);
break;
case PROP_FLOAT:
if (RNA_property_array_length(&but->rnapoin, prop))
if (RNA_property_array_check(prop))
RNA_property_float_set_index(&but->rnapoin, prop, but->rnaindex, value);
else
RNA_property_float_set(&but->rnapoin, prop, value);
@@ -3027,7 +3027,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
but->rnapoin = *ptr;
but->rnaprop = prop;
if (RNA_property_array_length(&but->rnapoin, but->rnaprop))
if (RNA_property_array_check(but->rnaprop))
but->rnaindex = index;
else
but->rnaindex = 0;

View File

@@ -144,7 +144,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
return 0;
}
if (RNA_property_array_length(&but->rnapoin, but->rnaprop) != 0) {
if (RNA_property_array_check(but->rnaprop) != 0) {
if (but->rnaindex == -1) {
if (G.debug & G_DEBUG)
printf("ERROR: create expression failed - can't create expression for entire array\n");

View File

@@ -1102,7 +1102,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem,
/* item is part of an array, so must set the array_index */
*array_index = te->index;
}
else if (RNA_property_array_length(ptr, prop)) {
else if (RNA_property_array_check(prop)) {
/* entire array was selected, so keyframe all */
*flag |= KSP_FLAG_WHOLE_ARRAY;
}