Fix #126568: add dropped asset collection to active collection

This is necessary for the case where we don't add an instance for it afterwards. The collection is always added, but it may be removed again in `collection_drop_exec` if "Instance" is enabled.

Pull Request: https://projects.blender.org/blender/blender/pulls/126648
This commit is contained in:
Jacques Lucke
2024-08-23 12:49:04 +02:00
parent c23bbadebf
commit 901cfac08b

View File

@@ -842,6 +842,7 @@ static void view3d_collection_drop_copy_external_asset(bContext *C, wmDrag *drag
{
BLI_assert(drag->type == WM_DRAG_ASSET);
Main *bmain = CTX_data_main(C);
wmDragAsset *asset_drag = WM_drag_get_asset_data(drag, 0);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
@@ -851,6 +852,11 @@ static void view3d_collection_drop_copy_external_asset(bContext *C, wmDrag *drag
ID *id = WM_drag_asset_id_import(C, asset_drag, FILE_AUTOSELECT);
Collection *collection = (Collection *)id;
BKE_view_layer_synced_ensure(scene, view_layer);
Collection *old_active_collection = BKE_view_layer_active_collection_get(view_layer)->collection;
BKE_collection_child_add(bmain, old_active_collection, collection);
DEG_id_tag_update(&old_active_collection->id, ID_RECALC_SYNC_TO_EVAL);
/* TODO(sergey): Only update relations for the current scene. */
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);