From 0d6dda4555bcae82cf581bdb23d639e9733057b5 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 23 May 2022 20:32:36 +0200 Subject: Cleanup: Move new utilities for ID lookup operator properties Move them to a more accessible place, so that other operators in different files can use them. The following commit needs this. --- source/blender/windowmanager/WM_api.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source/blender/windowmanager/WM_api.h') diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 525301d4393..67dc8797607 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -770,6 +770,27 @@ void WM_operator_properties_filesel(struct wmOperatorType *ot, eFileSel_Flag flag, short display, short sort); + +/** + * 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. + */ +struct ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(struct Main *bmain, + const struct wmOperator *op, + enum ID_Type type); +/** + * Adds "name" and "session_uuid" properties so the caller can tell the operator which ID to act + * on. See #WM_operator_properties_id_lookup_from_name_or_session_uuid(). Both properties will be + * hidden in the UI and not be saved over consecutive operator calls. + * + * \note New operators should probably use "session_uuid" only (set \a add_name_prop to #false), + * since this works properly with linked data and/or library overrides (in both cases, multiple IDs + * with the same name and type may be present). The "name" property is only kept to not break + * compatibility with old scripts using some previously existing operators. + */ +void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop); + /** * Disable using cursor position, * use when view operators are initialized from buttons. -- 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/windowmanager/WM_api.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/windowmanager/WM_api.h') 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 @@ -771,6 +771,15 @@ void WM_operator_properties_filesel(struct wmOperatorType *ot, short display, 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 -- cgit v1.2.3