Drag & drop: Invert priority of name and session UUID in ID lookups

Continuation of 8f79fa9c67 and 917c096be6. The ID's session UUID is
now always priotitized over its name to lookup the ID from drop-box or
operator properties. bc3dbf109c shows what happens if the name happens
to be set for whatever reason and the session UUID isn't prioritized.
This commit is contained in:
Julian Eisel
2022-05-24 15:32:30 +02:00
parent 961db61fb8
commit cd412b4454
2 changed files with 6 additions and 7 deletions

View File

@@ -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.
*/

View File

@@ -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;
}