Fix T53291: Deleting objects do not delete them from the blend file
authorDalai Felinto <dfelinto@gmail.com>
Mon, 27 Nov 2017 16:33:31 +0000 (14:33 -0200)
committerDalai Felinto <dfelinto@gmail.com>
Mon, 27 Nov 2017 16:52:21 +0000 (14:52 -0200)
User count was wrong for newly created files. We increase/decrease user count
when we link/delete objects from a SceneCollection.

So we don't want to leave user count of 1 after calling BKE_libblock_alloc in
BKE_object_add_only_object().

source/blender/blenkernel/intern/object.c
source/blender/makesrna/intern/rna_main_api.c

index 8fa4ebb8b3c4f9bece74f7df989d26730a736664..107e9299740a474ecc6e8bfc8c75a0ab1871f0b2 100644 (file)
@@ -706,6 +706,9 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
 
        ob = BKE_libblock_alloc(bmain, ID_OB, name, 0);
 
+       /* We increase object user count when linking to SceneCollections. */
+       id_us_min(&ob->id);
+
        /* default object vars */
        ob->type = type;
 
index d1b28bffc7ee847ebfdbb6ae9993c87b7a056942..f15006fa0ed520ac73d9afacd7d3486150486c81 100644 (file)
@@ -249,7 +249,6 @@ static Object *rna_Main_objects_new(Main *bmain, ReportList *reports, const char
        }
 
        ob = BKE_object_add_only_object(bmain, type, safe_name);
-       id_us_min(&ob->id);
 
        ob->data = data;
        test_object_materials(ob, ob->data);