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-01-24 22:57:57 +0300
committerJulian Eisel <julian@blender.org>2021-01-24 23:29:14 +0300
commite90a2a3f01f97e1a32f869ff63c8d80e15197860 (patch)
tree5dff7a266fd3097ef66109184ab99d4a4b116a12 /source/blender/windowmanager/intern/wm_event_system.c
parentf04206cbc7129603a7c437b79b1d1c99bd191783 (diff)
Asset Browser: Avoid appending asset data-block when drop operator will fail
For assets, the copy callback of the drop-box would append the asset data-block. Check if the operator's poll succeeds before calling the copy callback. Otherwise the data-block is "secretly" appended, which the user doesn't expect and won't notice without checking the file data in the Outliner. For masks I had to extend the poll function, it didn't check context sufficiently.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_event_system.c')
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index d08051dd5fb..67372675805 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2806,8 +2806,10 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
LISTBASE_FOREACH (wmDrag *, drag, lb) {
const char *tooltip = NULL;
if (drop->poll(C, drag, event, &tooltip)) {
- /* Optionally copy drag information to operator properties. */
- if (drop->copy) {
+ /* Optionally copy drag information to operator properties. Don't call it if the
+ * operator fails anyway, it might do more than just set properties (e.g.
+ * typically import an asset). */
+ if (drop->copy && WM_operator_poll_context(C, drop->ot, drop->opcontext)) {
drop->copy(drag, drop);
}