diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-20 07:09:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-20 07:09:24 +0400 |
commit | c64a9d8d41c118f2c4b40f2829873c03c14086de (patch) | |
tree | d058faffee786ceb50999403f206ed94186eaf0b /source/blender/makesrna/intern/rna_main_api.c | |
parent | 2ae4b2b687a917549fb392a41a26b24b45ae595e (diff) |
bugfix [#23910] Removing an object in Py crashes blender
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index b58ed4aab6a..b244d8ee5d3 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -175,22 +175,13 @@ Object *rna_Main_objects_new(Main *bmain, ReportList *reports, char* name, ID *d void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) { - /* - NOTE: the following example shows when this function should _not_ be called - - ob = bpy.data.add_object() - scene.add_object(ob) - - # ob is freed here - scene.remove_object(ob) - - # don't do this since ob is already freed! - bpy.data.remove_object(ob) - */ - if(ID_REAL_USERS(object) <= 0) + if(ID_REAL_USERS(object) <= 0) { + unlink_object(NULL, object); /* needed or ID pointers to this are not cleared */ free_libblock(&bmain->object, object); - else + } + else { BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, ID_REAL_USERS(object)); + } } struct Material *rna_Main_materials_new(Main *bmain, char* name) |