From 02c5ca2f2269b44cc56438847c55b8139a1c8dd2 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 23 May 2022 20:00:33 +0200 Subject: Fix possible issues when mixing link & append for asset drag & drop The operators to handle object drag and drop (from the asset browser, outliner, etc.) used the object name to find the object to add and place. This is problematic with linking and/or library overrides, since this may lead to multiple objects with the same name. So the wrong object would be used by the drop operators. Partially fixes T97320. T95706 probably needs the same fix but for materials. As a side-effect, the "Name" button won't show up in the Adjust Last Operation panel anymore. This isn't really useful, and I doubt this was ever intentionally exposed in the UI. --- source/blender/editors/space_view3d/space_view3d.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/space_view3d') diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index a02058fde6b..5ddfc4fe3cc 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -716,7 +716,7 @@ static void view3d_ob_drop_copy_local_id(bContext *UNUSED(C), wmDrag *drag, wmDr { ID *id = WM_drag_get_local_ID(drag, ID_OB); - RNA_string_set(drop->ptr, "name", id->name + 2); + RNA_int_set(drop->ptr, "session_uuid", id->session_uuid); /* Don't duplicate ID's which were just imported. Only do that for existing, local IDs. */ BLI_assert(drag->type != WM_DRAG_ASSET); @@ -751,7 +751,7 @@ static void view3d_ob_drop_copy_external_asset(bContext *UNUSED(C), wmDrag *drag DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); - RNA_string_set(drop->ptr, "name", id->name + 2); + RNA_int_set(drop->ptr, "session_uuid", id->session_uuid); Base *base = BKE_view_layer_base_find(view_layer, (Object *)id); if (base != NULL) { -- cgit v1.2.3 From 8f79fa9c6780dd5526dccce039c49bc7f69f47df Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 23 May 2022 20:54:15 +0200 Subject: Fix further issues when mixing link & append for asset drag & drop 917c096be6b9 applied to objects only, this also applies the same fix for the general 3D View drop operations, e.g. used for dragging materials, images, worlds, etc. This is needed to fix T95706, but apparently something else is still going on. Needs further investigation. --- source/blender/editors/space_view3d/space_view3d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_view3d') diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 5ddfc4fe3cc..e7732f07ed9 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -823,15 +823,15 @@ static void view3d_id_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *dr { ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, 0); - RNA_string_set(drop->ptr, "name", id->name + 2); + WM_operator_properties_id_lookup_set_from_id(drop->ptr, id); } static void view3d_id_drop_copy_with_type(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop) { ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, 0); - RNA_string_set(drop->ptr, "name", id->name + 2); RNA_enum_set(drop->ptr, "type", GS(id->name)); + WM_operator_properties_id_lookup_set_from_id(drop->ptr, id); } static void view3d_id_path_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop) @@ -839,7 +839,7 @@ static void view3d_id_path_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBo ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, 0); if (id) { - RNA_string_set(drop->ptr, "name", id->name + 2); + WM_operator_properties_id_lookup_set_from_id(drop->ptr, id); RNA_struct_property_unset(drop->ptr, "filepath"); } else if (drag->path[0]) { -- cgit v1.2.3