pin and driver id pointers were adding user references from rna but not on file load.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 28 Apr 2010 11:05:11 +0000 (11:05 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 28 Apr 2010 11:05:11 +0000 (11:05 +0000)
removing a reference to either could remove the object/data from the scene.
use set functions to avoid refcounting.

source/blender/makesrna/intern/rna_fcurve.c
source/blender/makesrna/intern/rna_space.c

index 7946e73af0f0501ae0cd1aa813bdabe4c8e4b84e..a8a73d15c9d9987bc41f7b961874f6e55d90612b 100644 (file)
@@ -155,6 +155,13 @@ static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA *
 
 /* ----------- */
 
+/* note: this function exists only to avoid id refcounting */
+static void rna_DriverTarget_id_set(PointerRNA *ptr, PointerRNA value)
+{
+    DriverTarget *dtar= (DriverTarget*)ptr->data;
+    dtar->id= value.data;
+}
+
 static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr)
 {
        DriverTarget *dtar= (DriverTarget*)ptr->data;
@@ -976,7 +983,8 @@ static void rna_def_drivertarget(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "ID");
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
-       RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_DriverTarget_id_typef");
+    /* note: custom set function is ONLY to avoid rna setting a user for this. */
+       RNA_def_property_pointer_funcs(prop, NULL, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef");
        RNA_def_property_ui_text(prop, "ID", "ID-block that the specific property used can be found from (id_type property must be set first)");
        RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
        
index 43b330fc43c2299e97f4a62e6ddc7398b439220e..f2c25e3e1fb17730b1777da7ca19a12d94117eaf 100644 (file)
@@ -492,6 +492,13 @@ static void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value)
 
 /* Space Properties */
 
+/* note: this function exists only to avoid id refcounting */
+static void rna_SpaceProperties_pin_id_set(PointerRNA *ptr, PointerRNA value)
+{
+    SpaceButs *sbuts= (SpaceButs*)(ptr->data);
+    sbuts->pinid= value.data;
+}
+
 static StructRNA *rna_SpaceProperties_pin_id_typef(PointerRNA *ptr)
 {
        SpaceButs *sbuts= (SpaceButs*)(ptr->data);
@@ -1193,7 +1200,8 @@ static void rna_def_space_buttons(BlenderRNA *brna)
        prop= RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE);
        RNA_def_property_pointer_sdna(prop, NULL, "pinid");
        RNA_def_property_struct_type(prop, "ID");
-       RNA_def_property_pointer_funcs(prop, NULL, NULL, "rna_SpaceProperties_pin_id_typef");
+    /* note: custom set function is ONLY to avoid rna setting a user for this. */
+       RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceProperties_pin_id_set", "rna_SpaceProperties_pin_id_typef");
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_PROPERTIES, NULL);