[Bf-blender-cvs] [cd412b4454f] master: Drag & drop: Invert priority of name and session UUID in ID lookups

Julian Eisel noreply at git.blender.org
Tue May 24 15:37:02 CEST 2022


Commit: cd412b4454f3cb89c5baf365d5404746332eac68
Author: Julian Eisel
Date:   Tue May 24 15:32:30 2022 +0200
Branches: master
https://developer.blender.org/rBcd412b4454f3cb89c5baf365d5404746332eac68

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.

===================================================================

M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_operator_props.c

===================================================================

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



More information about the Bf-blender-cvs mailing list