From 485b7424df5cb3474cc802bced77770d85bdcb37 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 28 Apr 2014 12:19:28 +0200 Subject: Avoid reentering processMouseEvents on embedded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-38597 Change-Id: I168c9401863bace711d0d8409bf3da30a34185bd Reviewed-by: Friedemann Kleint Reviewed-by: Jørgen Lind --- .../eglconvenience/qeglplatformcursor.cpp | 27 +++++++++++++++++++--- .../eglconvenience/qeglplatformcursor_p.h | 19 +++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp index 70e7c4e4db..e99581183e 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp @@ -69,7 +69,8 @@ QEGLPlatformCursor::QEGLPlatformCursor(QPlatformScreen *screen) m_vertexCoordEntry(0), m_textureCoordEntry(0), m_textureEntry(0), - m_deviceListener(0) + m_deviceListener(0), + m_updater(screen) { QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR"); if (!hideCursorVal.isEmpty()) @@ -270,12 +271,32 @@ bool QEGLPlatformCursor::setCurrentCursor(QCursor *cursor) } #endif -void QEGLPlatformCursor::update(const QRegion &rgn) +void QEGLPlatformCursorUpdater::update(const QPoint &pos, const QRegion &rgn) { - QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(m_cursor.pos), rgn); + m_active = false; + QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(pos), rgn); QWindowSystemInterface::flushWindowSystemEvents(); } +void QEGLPlatformCursorUpdater::scheduleUpdate(const QPoint &pos, const QRegion &rgn) +{ + if (m_active) + return; + + m_active = true; + + // Must not flush the window system events directly from here since we are likely to + // be a called directly from QGuiApplication's processMouseEvents. Flushing events + // could cause reentering by dispatching more queued mouse events. + QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection, + Q_ARG(QPoint, pos), Q_ARG(QRegion, rgn)); +} + +void QEGLPlatformCursor::update(const QRegion &rgn) +{ + m_updater.scheduleUpdate(m_cursor.pos, rgn); +} + QRect QEGLPlatformCursor::cursorRect() const { return QRect(m_cursor.pos - m_cursor.hotSpot, m_cursor.size); diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h index c9ff9a1198..6f4216874a 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcursor_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcursor_p.h @@ -68,6 +68,24 @@ private: int m_mouseCount; }; +class QEGLPlatformCursorUpdater : public QObject +{ + Q_OBJECT + +public: + QEGLPlatformCursorUpdater(QPlatformScreen *screen) + : m_screen(screen), m_active(false) { } + + void scheduleUpdate(const QPoint &pos, const QRegion &rgn); + +private slots: + void update(const QPoint &pos, const QRegion &rgn); + +private: + QPlatformScreen *m_screen; + bool m_active; +}; + class QEGLPlatformCursor : public QPlatformCursor { public: @@ -130,6 +148,7 @@ private: int m_textureCoordEntry; int m_textureEntry; QEGLPlatformCursorDeviceListener *m_deviceListener; + QEGLPlatformCursorUpdater m_updater; }; QT_END_NAMESPACE -- cgit v1.2.3