UI: Avoid showing drop hint on drag & drop if dropping won't succeed

If the poll check of the operator fails, the operator won't run. We can check
that in advance to hide the drop hint if dropping will fail anyway.
This improves feedback during dragging.
This commit is contained in:
Julian Eisel 2021-01-24 21:20:56 +01:00
parent e90a2a3f01
commit c8d6e2dfa0
Notes: blender-bot 2023-06-21 19:23:24 +02:00
Referenced by issue #85027, Crash dragging a collection over Outliner with active filter without matches
1 changed files with 2 additions and 1 deletions

View File

@ -225,7 +225,8 @@ static const char *dropbox_active(bContext *C,
if (handler->dropboxes) {
LISTBASE_FOREACH (wmDropBox *, drop, handler->dropboxes) {
const char *tooltip = NULL;
if (drop->poll(C, drag, event, &tooltip)) {
if (drop->poll(C, drag, event, &tooltip) &&
WM_operator_poll_context(C, drop->ot, drop->opcontext)) {
/* XXX Doing translation here might not be ideal, but later we have no more
* access to ot (and hence op context)... */
return (tooltip) ? tooltip : WM_operatortype_name(drop->ot, drop->ptr);