Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.2, 6.3, 6.4.2, 6.4, 6.5.0 Beta1
-
5.12.1, 5.15.10, 5.15.11
-
-
d194d32fc9 (qt/qtdeclarative/6.3) 10bb5cf3fc (qt/qtdeclarative/6.4) 0b7374fefa (qt/qtdeclarative/dev) 0b7374fefa (qt/qtdeclarative/wip/material3) d194d32fc9 (qt/tqtc-qtdeclarative/6.3) 10bb5cf3fc (qt/tqtc-qtdeclarative/6.4)
Description
I would expect that rejecting a drag event from a particular dragged Item would prevent a DropArea from receiving more drag events from the same dragged Item, at least until it exited the DropArea and re-entered.
Instead, the behavior observed is that every movement of the dragged Item within a DropArea re-triggers onEntered on the DropArea, even if the drag is rejected in onEntered handler of the DropArea.
This makes it very difficult to put significant processing code in onEntered for identifying whether to accept the drag and indicating this to the user through UI behavior. It becomes a performance issue.
Attached is a minimal reproduction example. Dragging an item over the window will cause "ENTERED" to be printed on every mouse movement, many times per second.
I believe that this is caused by the following code in qquickdroparea.cpp:
void QQuickDropArea::dragEnterEvent(QDragEnterEvent *event) { Q_D(QQuickDropArea); const QMimeData *mimeData = event->mimeData(); if (!d->effectiveEnable || d->containsDrag || !mimeData || !d->hasMatchingKey(d->getKeys(mimeData))) return; d->dragPosition = event->pos(); event->accept(); QQuickDropEvent dragTargetEvent(d, event); emit entered(&dragTargetEvent); if (!event->isAccepted()) return; d->containsDrag = true; ...
containsDrag is set after the check on whether the event is accepted, but is checked at the beginning for the early-return. Therefore, if the drag event is always rejected, then containsDrag will never be set true, and the entered signal will continue to be emitted.
Another negative side-effect of this is that containsDrag will be inaccurate if the drag is rejected. From the documentation for containsDrag:
"This property identifies whether the DropArea currently contains any dragged items."
This will not be as documented for a rejected dragged item.
UPDATE:
DragEnter causes a spike in the CPU profiler. When one has DropAreas that accepts a 'text/uri-list' type (the type of a file from the OS), With multiple Drag area this becomes worst. See No_keys_on_droparea_dragenter_is_expensive.png
Further these DragEnter events keep getting fired if dragging within a DropArea that does not accept the 'text/uri-list' type. This leads to causes massive slowdown for the entire duration that the dragging is occurring in these DropAreas. See Keys_that_dont_include_text/uri-list_dragEnter_always_firing.png
Attachments
Issue Links
- resulted in
-
QTBUG-107894 Support multi-mouse DnD: get rid of QDragManager
- Reported
For Gerrit Dashboard: QTBUG-74496 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
441062,7 | Fix performance issue with drag retrigger events for qtquick items | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
441944,2 | Fix performance issue with drag retrigger events for qtquick items | 6.4 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
441945,2 | Fix performance issue with drag retrigger events for qtquick items | 6.3 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
441951,2 | Fix performance issue with drag retrigger events for qtquick items | tqtc/lts-6.2 | qt/tqtc-qtdeclarative | Status: MERGED | +2 | 0 |
441952,1 | Fix performance issue with drag retrigger events for qtquick items | tqtc/lts-5.15 | qt/tqtc-qtdeclarative | Status: ABANDONED | 0 | 0 |