summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp14
-rw-r--r--src/widgets/kernel/qwidgetwindow_p.h2
2 files changed, 13 insertions, 3 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 98aed138aee..4cf2934a2dc 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -948,7 +948,17 @@ static QWidget *findDnDTarget(QWidget *parent, const QPoint &pos)
return widget;
}
-void QWidgetWindow::handleDragEnterEvent(QDragEnterEvent *event, QWidget *widget)
+/*!
+ \internal
+
+ Sends \a event to \a widget.
+
+ Also called from dragMoveEvent(), in which case \a event is-a
+ QDragMoveEvent only, not a full QDragEnterEvent, which is why this function
+ takes \a event as a QDragMoveEvent and not, as one would expect,
+ QDragEnterEvent (downcast would be UB).
+*/
+void QWidgetWindow::handleDragEnterEvent(QDragMoveEvent *event, QWidget *widget)
{
Q_ASSERT(m_dragTarget == nullptr);
if (!widget)
@@ -997,7 +1007,7 @@ void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event)
// widget might have been deleted when handling the leaveEvent
if (widget) {
// Send DragEnter to new widget.
- handleDragEnterEvent(static_cast<QDragEnterEvent*>(event), widget);
+ handleDragEnterEvent(event, widget);
// Handling 'DragEnter' should suffice for the application.
translated.setDropAction(event->dropAction());
translated.setAccepted(event->isAccepted());
diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h
index 717541142cd..342794ee3d3 100644
--- a/src/widgets/kernel/qwidgetwindow_p.h
+++ b/src/widgets/kernel/qwidgetwindow_p.h
@@ -65,7 +65,7 @@ protected:
void handleWheelEvent(QWheelEvent *);
#endif
#if QT_CONFIG(draganddrop)
- void handleDragEnterEvent(QDragEnterEvent *, QWidget *widget = nullptr);
+ void handleDragEnterEvent(QDragMoveEvent *, QWidget *widget = nullptr);
void handleDragMoveEvent(QDragMoveEvent *);
void handleDragLeaveEvent(QDragLeaveEvent *);
void handleDropEvent(QDropEvent *);