fix for assigning any ID in rna, it would not run id_lib_extern() which means the...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 16 Jul 2010 22:21:37 +0000 (22:21 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 16 Jul 2010 22:21:37 +0000 (22:21 +0000)
source/blender/makesrna/intern/makesrna.c

index 40f6c1de67e8fe8765dda3f241e11dd0188c3686..35b2eff9c62bb72846e2ead976378a9425a0701c 100644 (file)
@@ -628,6 +628,14 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr
                                        fprintf(f, "    if(value.data)\n");
                                        fprintf(f, "            id_us_plus((ID*)value.data);\n\n");
                                }
+                               else {
+                                       PointerPropertyRNA *pprop= (PointerPropertyRNA*)dp->prop;
+                                       StructRNA *type= rna_find_struct((char*)pprop->type);
+                                       if(type && (type->flag & STRUCT_ID)) {
+                                               fprintf(f, "    if(value.data)\n");
+                                               fprintf(f, "            id_lib_extern((ID*)value.data);\n\n");
+                                       }
+                               }
 
                                fprintf(f, "    data->%s= value.data;\n", dp->dnaname);