diff options
Diffstat (limited to 'src/gui/kernel/qsimpledrag.cpp')
-rw-r--r-- | src/gui/kernel/qsimpledrag.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp index a88955b99a..a90e8dd33c 100644 --- a/src/gui/kernel/qsimpledrag.cpp +++ b/src/gui/kernel/qsimpledrag.cpp @@ -34,9 +34,10 @@ Q_LOGGING_CATEGORY(lcDnd, "qt.gui.dnd") static QWindow* topLevelAt(const QPoint &pos) { - QWindowList list = QGuiApplication::topLevelWindows(); - for (int i = list.count()-1; i >= 0; --i) { - QWindow *w = list.at(i); + const QWindowList list = QGuiApplication::topLevelWindows(); + const auto crend = list.crend(); + for (auto it = list.crbegin(); it != crend; ++it) { + QWindow *w = *it; if (w->isVisible() && w->handle() && w->geometry().contains(pos) && !qobject_cast<QShapedPixmapWindow*>(w)) return w; } @@ -124,6 +125,7 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e) } case QEvent::MouseButtonRelease: { + QPointer<QObject> objGuard(o); disableEventFilter(); if (canDrop()) { QPoint nativePosition = getNativeMousePos(e, m_drag_icon_window); @@ -133,6 +135,8 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e) cancel(); } exitDndEventLoop(); + if (!objGuard) + return true; // If a QShapedPixmapWindow (drag feedback) is being dragged along, the // mouse event's localPos() will be relative to that, which is useless. @@ -306,7 +310,7 @@ static inline QPoint fromNativeGlobalPixels(const QPoint &point) #ifndef QT_NO_HIGHDPISCALING QPoint res = point; if (QHighDpiScaling::isActive()) { - for (const QScreen *s : qAsConst(QGuiApplicationPrivate::screen_list)) { + for (const QScreen *s : std::as_const(QGuiApplicationPrivate::screen_list)) { if (s->handle()->geometry().contains(point)) { res = QHighDpi::fromNativePixels(point, s); break; |