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>2021-02-16 17:24:22 +0300
committerJulian Eisel <julian@blender.org>2021-02-16 17:34:32 +0300
commite81fca1ed38ea447a1023dae3841f8980def28e4 (patch)
treed0d07de23c839fa147850fdc728d512eb17a6141 /source/blender/windowmanager/WM_api.h
parent500bc99da5dbcdf7c728833326fc29babaf529e0 (diff)
Assets: Remove appended asset when dropping operation fails
When dropping an asset somewhere, it is appended and then a drop operation is called to actually add it to the scene based on current context. If this drop operation fails, the appended data-block is now still in the .blend. The user may not notice and not expect this. Instead idea is to rollback any changes done by dropping code if the operation fails, namely removing the appended data-block again. Adds a new `cancel()` callback which is called if the drop operator returns `OPERATOR_CANCELLED` to drop-boxes and a generic function to deal with assets on drop failure. Also removes the `free_id_on_error` property of the `NODE_OT_add_group` operator, which was used as ad-hoc solution to get this same behavior.
Diffstat (limited to 'source/blender/windowmanager/WM_api.h')
-rw-r--r--source/blender/windowmanager/WM_api.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 69177f39c04..d5de45c74fd 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -678,7 +678,8 @@ struct wmDropBox *WM_dropbox_add(
ListBase *lb,
const char *idname,
bool (*poll)(struct bContext *, struct wmDrag *, const struct wmEvent *event, const char **),
- void (*copy)(struct wmDrag *, struct wmDropBox *));
+ void (*copy)(struct wmDrag *, struct wmDropBox *),
+ void (*cancel)(struct Main *, struct wmDrag *, struct wmDropBox *));
ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid);
/* ID drag and drop */
@@ -690,6 +691,10 @@ bool WM_drag_is_ID_type(const struct wmDrag *drag, int idcode);
struct wmDragAsset *WM_drag_get_asset_data(const struct wmDrag *drag, int idcode);
struct ID *WM_drag_get_local_ID_or_import_from_asset(const struct wmDrag *drag, int idcode);
+void WM_drag_free_imported_drag_ID(struct Main *bmain,
+ struct wmDrag *drag,
+ struct wmDropBox *drop);
+
/* Set OpenGL viewport and scissor */
void wmViewport(const struct rcti *winrct);
void wmPartialViewport(rcti *drawrct, const rcti *winrct, const rcti *partialrct);