diff options
author | Julian Eisel <julian@blender.org> | 2022-05-24 18:00:59 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-05-24 18:08:02 +0300 |
commit | b0da080c2cb951c167c6154de75e154532ab0f0d (patch) | |
tree | 339546b0aeb952fc4f31a1eceb9149cdc82303ec /source/blender/editors/object | |
parent | 7b778166db4048b5109146bc073ab85fa49261f4 (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/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.cc | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 35745bc7208..422aaa03120 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -1265,9 +1265,9 @@ void OBJECT_OT_drop_named_image(wmOperatorType *ot) "Relative Path", "Select the file relative to the blend file"); RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE)); - prop = RNA_def_string( - ot->srna, "name", nullptr, MAX_ID_NAME - 2, "Name", "Image name to assign"); - RNA_def_property_flag(prop, (PropertyFlag)(PROP_HIDDEN | PROP_SKIP_SAVE)); + + WM_operator_properties_id_lookup(ot, true); + ED_object_add_generic_props(ot, false); } @@ -1894,18 +1894,12 @@ static int object_data_instance_add_exec(bContext *C, wmOperator *op) ushort local_view_bits; float loc[3], rot[3]; - PropertyRNA *prop_name = RNA_struct_find_property(op->ptr, "name"); PropertyRNA *prop_type = RNA_struct_find_property(op->ptr, "type"); PropertyRNA *prop_location = RNA_struct_find_property(op->ptr, "location"); - /* These shouldn't fail when created by outliner dropping as it checks the ID is valid. */ - if (!RNA_property_is_set(op->ptr, prop_name) || !RNA_property_is_set(op->ptr, prop_type)) { - return OPERATOR_CANCELLED; - } const short id_type = RNA_property_enum_get(op->ptr, prop_type); - char name[MAX_ID_NAME - 2]; - RNA_property_string_get(op->ptr, prop_name, name); - id = BKE_libblock_find_name(bmain, id_type, name); + id = WM_operator_properties_id_lookup_from_name_or_session_uuid( + bmain, op->ptr, (ID_Type)id_type); if (id == nullptr) { return OPERATOR_CANCELLED; } @@ -1948,7 +1942,7 @@ void OBJECT_OT_data_instance_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_string(ot->srna, "name", "Name", MAX_ID_NAME - 2, "Name", "ID name to add"); + WM_operator_properties_id_lookup(ot, true); PropertyRNA *prop = RNA_def_enum(ot->srna, "type", rna_enum_id_type_items, 0, "Type", ""); RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID); ED_object_add_generic_props(ot, false); |