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 18:00:59 +0300
committerJulian Eisel <julian@blender.org>2022-05-24 18:08:02 +0300
commitb0da080c2cb951c167c6154de75e154532ab0f0d (patch)
tree339546b0aeb952fc4f31a1eceb9149cdc82303ec /source/blender/windowmanager/intern/wm_operators.c
parent7b778166db4048b5109146bc073ab85fa49261f4 (diff)
Drag & drop: Use session UUID of IDs instead of name for dropping
Dropping would pass the name of the ID to drop to the properties of the drop operator. This would then lookup the ID by name. With linking and/or library overrides, multiple IDs of the same name and type may exist, which is why the session UUID should be used instead. All operators used for dropping support this now and the drop code passes the session UUID instead of the name. Also see 917c096be6b9 and 8f79fa9c6780. Some drop operators were already using the session UUIDs. This converts the remaining ones. The "name" property is kept working as before, since some scripts use this. Side-effect: The "Name" property won't show up in the Adjust Last Operation anymore, which was the case for some of these operators, and its value won't be remembered over multiple executions of the operator. Both were not at all useful from what I can tell, and I doubt this was done intentionally.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_operators.c')
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index f455f7f2719..c3f2f9d15ca 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1266,6 +1266,7 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
{
Main *bmain = CTX_data_main(C);
ID *id = NULL;
+
/* check input variables */
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path");
@@ -1303,19 +1304,29 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
}
}
}
+
+ return id;
}
- else if (RNA_struct_property_is_set(op->ptr, "name")) {
- char name[MAX_ID_NAME - 2];
- RNA_string_get(op->ptr, "name", name);
- id = BKE_libblock_find_name(bmain, idcode, name);
- if (!id) {
+
+ /* Lookup an already existing ID. */
+ id = WM_operator_properties_id_lookup_from_name_or_session_uuid(bmain, op->ptr, idcode);
+
+ if (!id) {
+ /* Print error with the name if the name is available. */
+
+ if (RNA_struct_property_is_set(op->ptr, "name")) {
+ char name[MAX_ID_NAME - 2];
+ RNA_string_get(op->ptr, "name", name);
BKE_reportf(
op->reports, RPT_ERROR, "%s '%s' not found", BKE_idtype_idcode_to_name(idcode), name);
return NULL;
}
- id_us_plus(id);
+
+ BKE_reportf(op->reports, RPT_ERROR, "%s not found", BKE_idtype_idcode_to_name(idcode));
+ return NULL;
}
+ id_us_plus(id);
return id;
}