diff options
author | Julian Eisel <julian@blender.org> | 2022-05-24 16:23:13 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-05-24 16:23:13 +0300 |
commit | 961db61fb87fb5400bc0080e6a4d2e3fc16c1761 (patch) | |
tree | 0b4a5972d3998771a1ae5c8c563b5973c6bcb62a /source/blender/windowmanager | |
parent | 258f6cbf93678b7bfbd997a06ab0ec67571174b5 (diff) | |
parent | bc3dbf109c67fe2bced477774abdef7a53d66081 (diff) |
Merge branch 'blender-v3.2-release'
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_dragdrop.c | 13 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operator_props.c | 14 |
3 files changed, 12 insertions, 17 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index a29559e904e..8747acb5abe 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -786,7 +786,7 @@ void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id) * helper to add the properties. */ struct ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(struct Main *bmain, - const struct wmOperator *op, + PointerRNA *ptr, enum ID_Type type); /** * Adds "name" and "session_uuid" properties so the caller can tell the operator which ID to act diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index a98ded82a92..8f96080c810 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -683,15 +683,10 @@ void WM_drag_free_imported_drag_ID(struct Main *bmain, wmDrag *drag, wmDropBox * return; } - /* Get name from property, not asset data - it may have changed after importing to ensure - * uniqueness (name is assumed to be set from the imported ID name). */ - char name[MAX_ID_NAME - 2]; - RNA_string_get(drop->ptr, "name", name); - if (!name[0]) { - return; - } - - ID *id = BKE_libblock_find_name(bmain, asset_drag->id_type, name); + /* Try to find the imported ID. For this to work either a "session_uuid" or "name" property must + * have been defined (see #WM_operator_properties_id_lookup()). */ + ID *id = WM_operator_properties_id_lookup_from_name_or_session_uuid( + bmain, drop->ptr, asset_drag->id_type); if (id != NULL) { /* Do not delete the dragged ID if it has any user, otherwise if it is a 're-used' ID it will * cause T95636. Note that we need first to add the user that we want to remove in diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c index 55544e9906d..3476a16b02a 100644 --- a/source/blender/windowmanager/intern/wm_operator_props.c +++ b/source/blender/windowmanager/intern/wm_operator_props.c @@ -243,20 +243,20 @@ void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id) } ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain, - const wmOperator *op, + PointerRNA *ptr, const ID_Type type) { - PropertyRNA *prop_name = RNA_struct_find_property(op->ptr, "name"); - PropertyRNA *prop_session_uuid = RNA_struct_find_property(op->ptr, "session_uuid"); + PropertyRNA *prop_name = RNA_struct_find_property(ptr, "name"); + PropertyRNA *prop_session_uuid = RNA_struct_find_property(ptr, "session_uuid"); - if (prop_name && RNA_property_is_set(op->ptr, prop_name)) { + if (prop_name && RNA_property_is_set(ptr, prop_name)) { char name[MAX_ID_NAME - 2]; - RNA_property_string_get(op->ptr, prop_name, name); + RNA_property_string_get(ptr, prop_name, name); return BKE_libblock_find_name(bmain, type, name); } - if (prop_session_uuid && RNA_property_is_set(op->ptr, prop_session_uuid)) { - const uint32_t session_uuid = (uint32_t)RNA_property_int_get(op->ptr, prop_session_uuid); + if (prop_session_uuid && RNA_property_is_set(ptr, prop_session_uuid)) { + const uint32_t session_uuid = (uint32_t)RNA_property_int_get(ptr, prop_session_uuid); return BKE_libblock_find_session_uuid(bmain, type, session_uuid); } |