Fix T55344: linked collection instance has user count 0.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 6 Jun 2018 09:08:56 +0000 (11:08 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 6 Jun 2018 09:22:17 +0000 (11:22 +0200)
source/blender/blenloader/intern/readfile.c
source/blender/editors/object/object_group.c

index 4afde29d538927a66000daedae24e32f2b6e832b..a9f93dff9e625ddb122eb463caf12b698ae52ebe 100644 (file)
@@ -10064,6 +10064,7 @@ static void add_collections_to_scene(
 
                                /* Assign the collection. */
                                ob->dup_group = collection;
+                               id_us_plus(&collection->id);
                                ob->transflag |= OB_DUPLICOLLECTION;
                                copy_v3_v3(ob->loc, scene->cursor.location);
                        }
index debbe4bd3793ec26736fa497205cd9b0c82cbe95..8a52b6c5ef5d4bca57ce2c80d0e983b0b9938a63 100644 (file)
@@ -361,6 +361,7 @@ static int collection_create_exec(bContext *C, wmOperator *op)
        RNA_string_get(op->ptr, "name", name);
 
        Collection *collection = BKE_collection_add(bmain, NULL, name);
+       id_fake_user_set(&collection->id);
 
        CTX_DATA_BEGIN (C, Base *, base, selected_bases)
        {
@@ -402,6 +403,7 @@ static int collection_add_exec(bContext *C, wmOperator *UNUSED(op))
                return OPERATOR_CANCELLED;
 
        Collection *collection = BKE_collection_add(bmain, NULL, "Collection");
+       id_fake_user_set(&collection->id);
        BKE_collection_object_add(bmain, collection, ob);
 
        WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);