[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21105] branches/blender2.5/blender: small changes...

Campbell Barton ideasman42 at gmail.com
Tue Jun 23 14:36:15 CEST 2009


Revision: 21105
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21105
Author:   campbellbarton
Date:     2009-06-23 14:36:15 +0200 (Tue, 23 Jun 2009)

Log Message:
-----------
small changes...
- allow RNA_property_enum_items to take the totitems int pointer as NULL (spares a loop on all the enum items). this change also makes enums types with no enum array crash in some places, could support these though Id rather disallow them, generating docs is a quick way to test for this.
- open recent file operator used and enum to open the recent file without an enum array, changed to an int type.
- added space_logic.py poll functions

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/space_logic.py
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
    branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: branches/blender2.5/blender/release/ui/space_logic.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_logic.py	2009-06-23 12:15:14 UTC (rev 21104)
+++ branches/blender2.5/blender/release/ui/space_logic.py	2009-06-23 12:36:15 UTC (rev 21105)
@@ -5,6 +5,10 @@
 	__region_type__ = "UI"
 	__label__ = "Physics"
 
+	def poll(self, context):
+		ob = context.active_object
+		return ob and ob.game
+
 	def draw(self, context):
 		layout = self.layout
 		ob = context.active_object
@@ -56,6 +60,10 @@
 	__space_type__ = "LOGIC_EDITOR"
 	__region_type__ = "UI"
 	__label__ = "Collision Bounds"
+
+	def poll(self, context):
+		ob = context.active_object
+		return ob and ob.game
 	
 	def draw_header(self, context):
 		layout = self.layout

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c	2009-06-23 12:15:14 UTC (rev 21104)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c	2009-06-23 12:36:15 UTC (rev 21105)
@@ -643,25 +643,28 @@
 
 	if(eprop->itemf) {
 		*item= eprop->itemf(ptr);
-		for(tot=0; (*item)[tot].identifier; tot++);
-		*totitem= tot;
+		if(totitem) {
+			for(tot=0; (*item)[tot].identifier; tot++);
+			*totitem= tot;
+		}
 	}
 	else {
 		*item= eprop->item;
-		*totitem= eprop->totitem;
+		if(totitem)
+			*totitem= eprop->totitem;
 	}
 }
 
 int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value)
 {	
 	const EnumPropertyItem *item;
-	int totitem, i;
+	int i;
 	
-	RNA_property_enum_items(ptr, prop, &item, &totitem);
+	RNA_property_enum_items(ptr, prop, &item, NULL);
 	
-	for(i=0; i<totitem; i++) {
-		if(strcmp(item[i].identifier, identifier)==0) {
-			*value = item[i].value;
+	for(; item->identifier; item++) {
+		if(strcmp(item->identifier, identifier)==0) {
+			*value = item->value;
 			return 1;
 		}
 	}
@@ -693,11 +696,9 @@
 
 int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
 {	
-	const EnumPropertyItem *item;
-	int totitem;
+	const EnumPropertyItem *item= NULL;
 	
-	RNA_property_enum_items(ptr, prop, &item, &totitem);
-	
+	RNA_property_enum_items(ptr, prop, &item, NULL);
 	return RNA_enum_identifier(item, value, identifier);
 }
 
@@ -2067,14 +2068,13 @@
 {
 	PropertyRNA *prop= RNA_struct_find_property(ptr, name);
 	const EnumPropertyItem *item;
-	int a, totitem;
 
 	if(prop) {
-		RNA_property_enum_items(ptr, prop, &item, &totitem);
+		RNA_property_enum_items(ptr, prop, &item, NULL);
 
-		for(a=0; a<totitem; a++)
-			if(strcmp(item[a].identifier, enumname) == 0)
-				return (item[a].value == RNA_property_enum_get(ptr, prop));
+		for(; item->identifier; item++)
+			if(strcmp(item->identifier, enumname) == 0)
+				return (item->value == RNA_property_enum_get(ptr, prop));
 
 		printf("RNA_enum_is_equal: %s.%s item %s not found.\n", ptr->type->identifier, name, enumname);
 		return 0;

Modified: branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c	2009-06-23 12:15:14 UTC (rev 21104)
+++ branches/blender2.5/blender/source/blender/python/intern/bpy_rna.c	2009-06-23 12:36:15 UTC (rev 21105)
@@ -46,9 +46,9 @@
 
 static int mathutils_rna_vector_cb_index= -1; /* index for our callbacks */
 
-static int mathutils_rna_vector_check(PyObject *user)
+static int mathutils_rna_vector_check(BPy_PropertyRNA *self)
 {
-	return ((BPy_PropertyRNA *)user)->prop?1:0;
+	return self->prop?1:0;
 }
 
 static int mathutils_rna_vector_get(BPy_PropertyRNA *self, int subtype, float *vec_from)
@@ -190,7 +190,7 @@
 	const EnumPropertyItem *item;
 	int totitem;
 	
-	RNA_property_enum_items(ptr, prop, &item, &totitem);
+	RNA_property_enum_items(ptr, prop, &item, NULL);
 	return (char*)BPy_enum_as_string((EnumPropertyItem*)item);
 }
 

Modified: branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c	2009-06-23 12:15:14 UTC (rev 21104)
+++ branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c	2009-06-23 12:36:15 UTC (rev 21105)
@@ -503,7 +503,7 @@
 
 static int recentfile_exec(bContext *C, wmOperator *op)
 {
-	int event= RNA_enum_get(op->ptr, "nr");
+	int event= RNA_int_get(op->ptr, "nr");
 
 	// XXX wm in context is not set correctly after WM_read_file -> crash
 	// do it before for now, but is this correct with multiple windows?
@@ -557,7 +557,7 @@
 	ot->exec= recentfile_exec;
 	ot->poll= WM_operator_winactive;
 	
-	RNA_def_property(ot->srna, "nr", PROP_ENUM, PROP_NONE);
+	RNA_def_property(ot->srna, "nr", PROP_INT, PROP_UNSIGNED);
 }
 
 /* ********* main file *********** */





More information about the Bf-blender-cvs mailing list