Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-07 08:05:41 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-07 08:05:41 +0300
commitad8c79405ac053bafea606ee954c4324d066d5fa (patch)
tree6f4a92c29fbc134330118a94f39b2665c7c0c0a9 /source
parenta018bfba9ad925e563dfa7f1512b2e5925547ea1 (diff)
Type checks for internal ID-Property UI min/max/tip & use defines to get values from ID-Props.
Probably wouldn't cause a problem but manually editing these types through python could easily crash blender. also changed cmake, stub-makefile default build dir to be lower case and leave out architecture string, easier for documentation. Use ../build/linux/ rather then ../build/Linux_i686/
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_idprop.h2
-rw-r--r--source/blender/blenkernel/intern/idprop.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c4
-rw-r--r--source/blender/makesrna/intern/rna_access.c76
4 files changed, 50 insertions, 38 deletions
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h
index 701cffc7743..0ca5690e635 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -127,6 +127,8 @@ int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop);
IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name);
+/* same as above but ensure type match */
+IDProperty *IDP_GetPropertyTypeFromGroup(struct IDProperty *prop, const char *name, const char type);
/*Get an iterator to iterate over the members of an id property group.
Note that this will automatically free the iterator once iteration is complete;
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 633d3aeafb9..7829d9b5e0d 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -535,6 +535,12 @@ IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name)
return (IDProperty *)BLI_findstring(&prop->data.group, name, offsetof(IDProperty, name));
}
+IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type)
+{
+ IDProperty *idprop= IDP_GetPropertyFromGroup(prop, name);
+ return (idprop && idprop->type == type) ? idprop : NULL;
+}
+
typedef struct IDPIter {
void *next;
IDProperty *parent;
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index ba73c488c46..6a8d5043c43 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -5452,10 +5452,10 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
idgroup= IDP_GetProperties(&image->id, 0);
if(idgroup) {
- view_data= IDP_GetPropertyFromGroup(idgroup, PROJ_VIEW_DATA_ID);
+ view_data= IDP_GetPropertyTypeFromGroup(idgroup, PROJ_VIEW_DATA_ID, IDP_ARRAY);
/* type check to make sure its ok */
- if(view_data->len != PROJ_VIEW_DATA_SIZE || view_data->type != IDP_ARRAY || view_data->subtype != IDP_FLOAT) {
+ if(view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT) {
BKE_report(op->reports, RPT_ERROR, "Image project data invalid.");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 6c09b349d9b..b8e14a9bba5 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -235,8 +235,9 @@ IDProperty *rna_idproperty_ui(PropertyRNA *prop)
}
}
- if (idprop)
- return IDP_GetPropertyFromGroup(idprop, ((IDProperty *)prop)->name);
+ if (idprop) {
+ return IDP_GetPropertyTypeFromGroup(idprop, ((IDProperty *)prop)->name, IDP_GROUP);
+ }
return NULL;
}
@@ -447,11 +448,10 @@ static const char *rna_ensure_property_description(PropertyRNA *prop)
/* attempt to get the local ID values */
IDProperty *idp_ui= rna_idproperty_ui(prop);
- if(idp_ui) { /* TODO, type checking on ID props */
-
- IDProperty *item= IDP_GetPropertyFromGroup(idp_ui, "description");
+ if(idp_ui) {
+ IDProperty *item= IDP_GetPropertyTypeFromGroup(idp_ui, "description", IDP_STRING);
if(item)
- return (char *)item->data.pointer ;
+ return IDP_String(item);
}
return ((IDProperty*)prop)->name; /* XXX - not correct */
@@ -803,14 +803,15 @@ void RNA_property_int_range(PointerRNA *ptr, PropertyRNA *prop, int *hardmin, in
if(prop->magic != RNA_MAGIC) {
/* attempt to get the local ID values */
IDProperty *idp_ui= rna_idproperty_ui(prop);
- IDProperty *item;
- if(idp_ui) { /* TODO, type checking on ID props */
- item= IDP_GetPropertyFromGroup(idp_ui, "min");
- *hardmin= item ? item->data.val : INT_MIN;
+ if(idp_ui) {
+ IDProperty *item;
- item= IDP_GetPropertyFromGroup(idp_ui, "max");
- *hardmax= item ? item->data.val : INT_MAX;
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "min", IDP_INT);
+ *hardmin= item ? IDP_Int(item) : INT_MIN;
+
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "max", IDP_INT);
+ *hardmax= item ? IDP_Int(item) : INT_MAX;
return;
}
@@ -833,17 +834,18 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin,
if(prop->magic != RNA_MAGIC) {
/* attempt to get the local ID values */
IDProperty *idp_ui= rna_idproperty_ui(prop);
- IDProperty *item;
- if(idp_ui) { /* TODO, type checking on ID props */
- item= IDP_GetPropertyFromGroup(idp_ui, "soft_min");
- *softmin= item ? item->data.val : INT_MIN;
+ if(idp_ui) {
+ IDProperty *item;
- item= IDP_GetPropertyFromGroup(idp_ui, "soft_max");
- *softmax= item ? item->data.val : INT_MAX;
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "soft_min", IDP_INT);
+ *softmin= item ? IDP_Int(item) : INT_MIN;
- item= IDP_GetPropertyFromGroup(idp_ui, "step");
- *step= item ? item->data.val : 1;
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "soft_max", IDP_INT);
+ *softmax= item ? IDP_Int(item) : INT_MAX;
+
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "step", IDP_INT);
+ *step= item ? IDP_Int(item) : 1;
return;
}
@@ -869,14 +871,15 @@ void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin
if(prop->magic != RNA_MAGIC) {
/* attempt to get the local ID values */
IDProperty *idp_ui= rna_idproperty_ui(prop);
- IDProperty *item;
- if(idp_ui) { /* TODO, type checking on ID props */
- item= IDP_GetPropertyFromGroup(idp_ui, "min");
- *hardmin= item ? *(double*)&item->data.val : FLT_MIN;
+ if(idp_ui) {
+ IDProperty *item;
+
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "min", IDP_DOUBLE);
+ *hardmin= item ? IDP_Double(item) : FLT_MIN;
- item= IDP_GetPropertyFromGroup(idp_ui, "max");
- *hardmax= item ? *(double*)&item->data.val : FLT_MAX;
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "max", IDP_DOUBLE);
+ *hardmax= item ? IDP_Double(item) : FLT_MAX;
return;
}
@@ -899,20 +902,21 @@ void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *soft
if(prop->magic != RNA_MAGIC) {
/* attempt to get the local ID values */
IDProperty *idp_ui= rna_idproperty_ui(prop);
- IDProperty *item;
- if(idp_ui) { /* TODO, type checking on ID props */
- item= IDP_GetPropertyFromGroup(idp_ui, "soft_min");
- *softmin= item ? *(double*)&item->data.val : FLT_MIN;
+ if(idp_ui) {
+ IDProperty *item;
+
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "soft_min", IDP_DOUBLE);
+ *softmin= item ? IDP_Double(item) : FLT_MIN;
- item= IDP_GetPropertyFromGroup(idp_ui, "soft_max");
- *softmax= item ? *(double*)&item->data.val : FLT_MAX;
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "soft_max", IDP_DOUBLE);
+ *softmax= item ? IDP_Double(item) : FLT_MAX;
- item= IDP_GetPropertyFromGroup(idp_ui, "step");
- *step= item ? *(double*)&item->data.val : 1.0f;
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "step", IDP_DOUBLE);
+ *step= item ? IDP_Double(item) : 1.0f;
- item= IDP_GetPropertyFromGroup(idp_ui, "precision");
- *precision= item ? *(double*)&item->data.val : 3.0f;
+ item= IDP_GetPropertyTypeFromGroup(idp_ui, "precision", IDP_DOUBLE);
+ *precision= item ? IDP_Double(item) : 3.0f;
return;
}