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 15:22:59 +0300
committerJulian Eisel <julian@blender.org>2022-05-24 16:21:38 +0300
commit463077a3d59df3de8a8fdc218c06c38116829f3e (patch)
tree5b95ac5f6c7bff7734672070af0b11e9e737e315 /source/blender/windowmanager/intern/wm_dragdrop.c
parenta40a26906213c2730c8b2efd9a509e18c7821e87 (diff)
Fix possible lingering around of ID after asset dropping failed
More and more of the drop operations are being switched to use the ID's session UUID rather than the name, but the cleanup after a drop operator was cancelled assumed they would set the name. They will now first attempt to use the session UUID and fallback to the name if needed.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_dragdrop.c')
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index a98ded82a92..8f96080c810 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -683,15 +683,10 @@ void WM_drag_free_imported_drag_ID(struct Main *bmain, wmDrag *drag, wmDropBox *
return;
}
- /* Get name from property, not asset data - it may have changed after importing to ensure
- * uniqueness (name is assumed to be set from the imported ID name). */
- char name[MAX_ID_NAME - 2];
- RNA_string_get(drop->ptr, "name", name);
- if (!name[0]) {
- return;
- }
-
- ID *id = BKE_libblock_find_name(bmain, asset_drag->id_type, name);
+ /* Try to find the imported ID. For this to work either a "session_uuid" or "name" property must
+ * have been defined (see #WM_operator_properties_id_lookup()). */
+ ID *id = WM_operator_properties_id_lookup_from_name_or_session_uuid(
+ bmain, drop->ptr, asset_drag->id_type);
if (id != NULL) {
/* Do not delete the dragged ID if it has any user, otherwise if it is a 're-used' ID it will
* cause T95636. Note that we need first to add the user that we want to remove in