[Bf-blender-cvs] [bbe5a95d05f] master: Fix T58875: object paste and append Active Collection property not working.

Brecht Van Lommel noreply at git.blender.org
Thu Feb 28 13:03:32 CET 2019


Commit: bbe5a95d05f7c9c7286e8f785ac92c2e16a114b2
Author: Brecht Van Lommel
Date:   Thu Feb 28 13:00:38 2019 +0100
Branches: master
https://developer.blender.org/rBbbe5a95d05f7c9c7286e8f785ac92c2e16a114b2

Fix T58875: object paste and append Active Collection property not working.

===================================================================

M	source/blender/blenloader/intern/readfile.c

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index c0bf832a768..250c4aacfc6 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -10791,22 +10791,11 @@ static bool object_in_any_scene(Main *bmain, Object *ob)
 	return false;
 }
 
-static Collection *get_collection_active(
-	Main *bmain, Scene *scene, ViewLayer *view_layer, const int flag)
-{
-	if (flag & FILE_ACTIVE_COLLECTION) {
-		LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
-		return lc->collection;
-	}
-	else {
-		return BKE_collection_add(bmain, scene->master_collection, NULL);
-	}
-}
-
 static void add_loose_objects_to_scene(
         Main *mainvar, Main *bmain,
         Scene *scene, ViewLayer *view_layer, const View3D *v3d, Library *lib, const short flag)
 {
+	Collection *active_collection = NULL;
 	const bool is_link = (flag & FILE_LINK) != 0;
 
 	BLI_assert(scene);
@@ -10827,10 +10816,20 @@ static void add_loose_objects_to_scene(
 			}
 
 			if (do_it) {
+				/* Find or add collection as needed. */
+				if (active_collection == NULL) {
+					if (flag & FILE_ACTIVE_COLLECTION) {
+						LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
+						active_collection = lc->collection;
+					}
+					else {
+						active_collection = BKE_collection_add(bmain, scene->master_collection, NULL);
+					}
+				}
+
 				CLAMP_MIN(ob->id.us, 0);
 				ob->mode = OB_MODE_OBJECT;
 
-				Collection *active_collection = get_collection_active(bmain, scene, view_layer, FILE_ACTIVE_COLLECTION);
 				BKE_collection_object_add(bmain, active_collection, ob);
 				Base *base = BKE_view_layer_base_find(view_layer, ob);
 
@@ -10859,7 +10858,11 @@ static void add_collections_to_scene(
         Main *mainvar, Main *bmain,
         Scene *scene, ViewLayer *view_layer, const View3D *v3d, Library *lib, const short flag)
 {
-	Collection *active_collection = get_collection_active(bmain, scene, view_layer, FILE_ACTIVE_COLLECTION);
+	Collection *active_collection = scene->master_collection;
+	if (flag & FILE_ACTIVE_COLLECTION) {
+		LayerCollection *lc = BKE_layer_collection_get_active(view_layer);
+		active_collection = lc->collection;
+	}
 
 	/* Give all objects which are tagged a base. */
 	for (Collection *collection = mainvar->collection.first; collection; collection = collection->id.next) {



More information about the Bf-blender-cvs mailing list