diff options
author | Julian Eisel <julian@blender.org> | 2022-05-23 21:54:15 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-05-23 22:00:01 +0300 |
commit | 8f79fa9c6780dd5526dccce039c49bc7f69f47df (patch) | |
tree | 25c22e1473eb5967cf07058d22a5f49947894cf8 /source/blender/windowmanager | |
parent | 0d6dda4555bcae82cf581bdb23d639e9733057b5 (diff) |
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.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 9 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operator_props.c | 16 |
2 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 67dc8797607..48ade798364 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -772,6 +772,15 @@ void WM_operator_properties_filesel(struct wmOperatorType *ot, short sort); /** + * Tries to pass \a id to an operator via either a "session_uuid" or a "name" property defined in + * the properties of \a ptr. The former is preferred, since it works properly with linking and + * library overrides (which may both result in multiple IDs with the same name and type). + * + * Also see #WM_operator_properties_id_lookup() and + * #WM_operator_properties_id_lookup_from_name_or_session_uuid() + */ +void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id); +/** * Tries to find an ID in \a bmain. There needs to be either a "name" string or "session_uuid" int * property defined and set. The former has priority. See #WM_operator_properties_id_lookup() for a * helper to add the properties. diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c index b58121794b3..55544e9906d 100644 --- a/source/blender/windowmanager/intern/wm_operator_props.c +++ b/source/blender/windowmanager/intern/wm_operator_props.c @@ -226,6 +226,22 @@ void WM_operator_properties_filesel(wmOperatorType *ot, RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } +void WM_operator_properties_id_lookup_set_from_id(PointerRNA *ptr, const ID *id) +{ + PropertyRNA *prop_session_uuid = RNA_struct_find_property(ptr, "session_uuid"); + PropertyRNA *prop_name = RNA_struct_find_property(ptr, "name"); + + if (prop_session_uuid) { + RNA_int_set(ptr, "session_uuid", (int)id->session_uuid); + } + else if (prop_name) { + RNA_string_set(ptr, "name", id->name + 2); + } + else { + BLI_assert_unreachable(); + } +} + ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain, const wmOperator *op, const ID_Type type) |