[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21040] branches/soc-2009-kazanbas/source/ blender/makesrna/intern: * Object.create_dupli_list, Object. free_dupli_list tweaking

Arystanbek Dyussenov arystan.d at gmail.com
Sat Jun 20 22:08:11 CEST 2009


Revision: 21040
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21040
Author:   kazanbas
Date:     2009-06-20 22:08:11 +0200 (Sat, 20 Jun 2009)

Log Message:
-----------
* Object.create_dupli_list, Object.free_dupli_list tweaking
* Defined custom "get" function for DupliObject.object

Accessing Object.dupli_list[N].object produces a crash.

Modified Paths:
--------------
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object.c
    branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object_api.c

Modified: branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object.c	2009-06-20 16:48:58 UTC (rev 21039)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object.c	2009-06-20 20:08:11 UTC (rev 21040)
@@ -364,6 +364,14 @@
 	}
 }
 
+static PointerRNA rna_DupliObject_object_get(PointerRNA *ptr)
+{
+	DupliObject *dob= (DupliObject*)ptr->data;
+	PointerRNA newptr;
+	RNA_pointer_create(&dob->ob->id, &RNA_Object, dob->ob, &newptr);
+	return newptr;
+}
+
 #else
 
 static void rna_def_vertex_group(BlenderRNA *brna)
@@ -1167,8 +1175,9 @@
 	/* RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA); */
 
 	prop= RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
+	RNA_def_property_struct_type(prop, "Object");
 	RNA_def_property_pointer_sdna(prop, NULL, "ob");
-	RNA_def_property_struct_type(prop, "Object");
+	RNA_def_property_pointer_funcs(prop, "rna_DupliObject_object_get", NULL, NULL);
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Object", "Object this DupliObject represents.");
 

Modified: branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object_api.c
===================================================================
--- branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object_api.c	2009-06-20 16:48:58 UTC (rev 21039)
+++ branches/soc-2009-kazanbas/source/blender/makesrna/intern/rna_object_api.c	2009-06-20 20:08:11 UTC (rev 21040)
@@ -108,20 +108,19 @@
 		return;
 	}
 
-	sce= CTX_data_scene(C);
-
 	RNA_id_pointer_create(&ob->id, &obptr);
 
 	if (!(prop= RNA_struct_find_property(&obptr, OBJECT_API_PROP_DUPLILIST))) {
 		// hint: all Objects will now have this property defined
-		prop= RNA_def_collection_runtime(obptr.type, OBJECT_API_PROP_DUPLILIST, &RNA_DupliObject, "Dupli list", "List of object's duplis");
+		prop= RNA_def_collection_runtime(obptr.type, OBJECT_API_PROP_DUPLILIST, &RNA_DupliObject, "Dupli list", "");
 	}
 
 	RNA_property_collection_clear(&obptr, prop);
+	sce= CTX_data_scene(C);
 	ob->duplilist= object_duplilist(sce, ob);
 
 	for(dob= (DupliObject*)ob->duplilist->first; dob; dob= dob->next) {
-		RNA_pointer_create(NULL, &RNA_Object, dob, &dobptr);
+		RNA_pointer_create(NULL, &RNA_DupliObject, dob, &dobptr);
 		RNA_property_collection_add(&obptr, prop, &dobptr);
 		dob = dob->next;
 	}
@@ -143,8 +142,10 @@
 
 	RNA_property_collection_clear(&obptr, prop);
 
-	free_object_duplilist(ob->duplilist);
-	ob->duplilist= NULL;
+	if (ob->duplilist) {
+		free_object_duplilist(ob->duplilist);
+		ob->duplilist= NULL;
+	}
 }
 
 #else





More information about the Bf-blender-cvs mailing list