Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2022-05-24 16:32:30 +0300
committerJulian Eisel <julian@blender.org>2022-05-24 16:36:41 +0300
commitcd412b4454f3cb89c5baf365d5404746332eac68 (patch)
treee9cf1195bf1d5eebe79a73cbae4de176fd48d5a7 /source/blender/windowmanager
parent961db61fb87fb5400bc0080e6a4d2e3fc16c1761 (diff)
Drag & drop: Invert priority of name and session UUID in ID lookups
Continuation of 8f79fa9c6780 and 917c096be6b9. The ID's session UUID is now always priotitized over its name to lookup the ID from drop-box or operator properties. bc3dbf109c67 shows what happens if the name happens to be set for whatever reason and the session UUID isn't prioritized.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_api.h2
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c11
2 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 8747acb5abe..12cafbd7c64 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -781,7 +781,7 @@ void WM_operator_properties_filesel(struct wmOperatorType *ot,
*/
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
+ * Tries to find an ID in \a bmain. There needs to be either a "session_uuid" int or "name" string
* 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 3476a16b02a..96f711bb237 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -246,20 +246,19 @@ ID *WM_operator_properties_id_lookup_from_name_or_session_uuid(Main *bmain,
PointerRNA *ptr,
const ID_Type type)
{
- PropertyRNA *prop_name = RNA_struct_find_property(ptr, "name");
PropertyRNA *prop_session_uuid = RNA_struct_find_property(ptr, "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);
+ }
+ PropertyRNA *prop_name = RNA_struct_find_property(ptr, "name");
if (prop_name && RNA_property_is_set(ptr, prop_name)) {
char name[MAX_ID_NAME - 2];
RNA_property_string_get(ptr, prop_name, name);
return BKE_libblock_find_name(bmain, type, name);
}
- 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);
- }
-
return NULL;
}