Revision: 34680
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34680
Author:   campbellbarton
Date:     2011-02-07 05:05:41 +0000 (Mon, 07 Feb 2011)
Log Message:
-----------
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/

Modified Paths:
--------------
    trunk/blender/GNUmakefile
    trunk/blender/source/blender/blenkernel/BKE_idprop.h
    trunk/blender/source/blender/blenkernel/intern/idprop.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/makesrna/intern/rna_access.c

Modified: trunk/blender/GNUmakefile
===================================================================
--- trunk/blender/GNUmakefile   2011-02-07 01:45:52 UTC (rev 34679)
+++ trunk/blender/GNUmakefile   2011-02-07 05:05:41 UTC (rev 34680)
@@ -28,12 +28,13 @@
 
 # System Vars
 OS:=$(shell uname -s)
-CPU:=$(shell uname -m)
+OS_NCASE:=$(shell uname -s | tr '[A-Z]' '[a-z]')
+# CPU:=$(shell uname -m)  # UNUSED
 
 
 # Source and Build DIR's
 BLENDER_DIR:=$(shell pwd -P)
-BUILD_DIR:=$(shell dirname $(BLENDER_DIR))/build/$(OS)_$(CPU)
+BUILD_DIR:=$(shell dirname $(BLENDER_DIR))/build/$(OS_NCASE)
 
 
 # Get the number of cores for threaded build

Modified: trunk/blender/source/blender/blenkernel/BKE_idprop.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_idprop.h        2011-02-07 
01:45:52 UTC (rev 34679)
+++ trunk/blender/source/blender/blenkernel/BKE_idprop.h        2011-02-07 
05:05:41 UTC (rev 34680)
@@ -127,6 +127,8 @@
 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;

Modified: trunk/blender/source/blender/blenkernel/intern/idprop.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/idprop.c     2011-02-07 
01:45:52 UTC (rev 34679)
+++ trunk/blender/source/blender/blenkernel/intern/idprop.c     2011-02-07 
05:05:41 UTC (rev 34680)
@@ -535,6 +535,12 @@
        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;

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c     
2011-02-07 01:45:52 UTC (rev 34679)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c     
2011-02-07 05:05:41 UTC (rev 34680)
@@ -5452,10 +5452,10 @@
        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;
                }

Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c   2011-02-07 
01:45:52 UTC (rev 34679)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c   2011-02-07 
05:05:41 UTC (rev 34680)
@@ -235,8 +235,9 @@
                }
        }
 
-       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 @@
                /* 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,15 +803,16 @@
        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,18 +834,19 @@
        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,15 +871,16 @@
        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_GetPropertyFromGroup(idp_ui, "max");
-                       *hardmax= item ? *(double*)&item->data.val : FLT_MAX;
+                       item= IDP_GetPropertyTypeFromGroup(idp_ui, "min", 
IDP_DOUBLE);
+                       *hardmin= item ? IDP_Double(item) : FLT_MIN; 
 
+                       item= IDP_GetPropertyTypeFromGroup(idp_ui, "max", 
IDP_DOUBLE);
+                       *hardmax= item ? IDP_Double(item) : FLT_MAX;
+
                        return;
                }
        }
@@ -899,21 +902,22 @@
        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_GetPropertyFromGroup(idp_ui, "soft_max");
-                       *softmax= item ? *(double*)&item->data.val : FLT_MAX;
+                       item= IDP_GetPropertyTypeFromGroup(idp_ui, "soft_min", 
IDP_DOUBLE);
+                       *softmin= item ? IDP_Double(item) : FLT_MIN;
 
-                       item= IDP_GetPropertyFromGroup(idp_ui, "step");
-                       *step= item ? *(double*)&item->data.val : 1.0f;
+                       item= IDP_GetPropertyTypeFromGroup(idp_ui, "soft_max", 
IDP_DOUBLE);
+                       *softmax= item ? IDP_Double(item) : FLT_MAX;
 
-                       item= IDP_GetPropertyFromGroup(idp_ui, "precision");
-                       *precision= item ? *(double*)&item->data.val : 3.0f;
+                       item= IDP_GetPropertyTypeFromGroup(idp_ui, "step", 
IDP_DOUBLE);
+                       *step= item ? IDP_Double(item) : 1.0f;
 
+                       item= IDP_GetPropertyTypeFromGroup(idp_ui, "precision", 
IDP_DOUBLE);
+                       *precision= item ? IDP_Double(item) : 3.0f;
+
                        return;
                }
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to