From 12262adebad5e4af2cf2c9a6dd41a941c78f1988 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Mon, 11 Jul 2022 14:39:30 +0200 Subject: [PATCH] Do not use QExposedEvent::region() in internal code Task-number: QTBUG-104857 Pick-to: 6.4 6.3 6.2 Change-Id: I5ee41802ecc4d6291aaaa1f0efddd20027c1c1e4 Reviewed-by: Volker Hilsheimer --- src/gui/kernel/qevent.cpp | 5 +--- src/gui/kernel/qevent.h | 1 + src/widgets/kernel/qwidgetwindow.cpp | 7 ++---- .../qbackingstore/tst_qbackingstore.cpp | 5 +--- tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 23 ------------------- 5 files changed, 5 insertions(+), 36 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index b1ad2753fe..fe1a748cbe 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -3989,10 +3989,7 @@ QDebug operator<<(QDebug dbg, const QEvent *e) bool isMouse = false; switch (type) { case QEvent::Expose: -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - dbg << "QExposeEvent(" << static_cast(e)->region() << ')'; -QT_WARNING_POP + dbg << "QExposeEvent()"; break; case QEvent::Paint: dbg << "QPaintEvent(" << static_cast(e)->region() << ')'; diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 983cc6a9da..7bca2b2931 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -520,6 +520,7 @@ public: protected: QRegion m_region; + friend class QWidgetWindow; }; class Q_GUI_EXPORT QPlatformSurfaceEvent : public QEvent diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index c1fcdbb2dd..61dfa5b2f1 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -1002,11 +1002,8 @@ void QWidgetWindow::handleExposeEvent(QExposeEvent *event) m_widget->setAttribute(Qt::WA_Mapped); for (QWidget *p = m_widget->parentWidget(); p && !p->testAttribute(Qt::WA_Mapped); p = p->parentWidget()) p->setAttribute(Qt::WA_Mapped); -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - if (!event->region().isNull()) - wPriv->syncBackingStore(event->region()); -QT_WARNING_POP + if (!event->m_region.isNull()) + wPriv->syncBackingStore(event->m_region); } else { m_widget->setAttribute(Qt::WA_Mapped, false); } diff --git a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp index 0406fe0f07..d9528fc8e4 100644 --- a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp +++ b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp @@ -239,7 +239,7 @@ public: backingStore.resize(size()); } - void exposeEvent(QExposeEvent *event) override + void paintEvent(QPaintEvent *event) override { QRect rect(QPoint(), size()); @@ -251,10 +251,7 @@ public: backingStore.endPaint(); -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED backingStore.flush(event->region().boundingRect()); -QT_WARNING_POP } private: diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 1eefcb32cf..ee2721c375 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -287,13 +287,6 @@ public: m_received[event->type()]++; m_order << event->type(); switch (event->type()) { - case QEvent::Expose: -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - m_exposeRegion = static_cast(event)->region(); -QT_WARNING_POP - break; - case QEvent::PlatformSurface: m_surfaceventType = static_cast(event)->surfaceEventType(); break; @@ -323,11 +316,6 @@ QT_WARNING_POP return m_order.indexOf(type); } - QRegion exposeRegion() const - { - return m_exposeRegion; - } - QPlatformSurfaceEvent::SurfaceEventType surfaceEventType() const { return m_surfaceventType; @@ -339,7 +327,6 @@ QT_WARNING_POP private: QHash m_received; QList m_order; - QRegion m_exposeRegion; QPlatformSurfaceEvent::SurfaceEventType m_surfaceventType; }; @@ -797,16 +784,6 @@ void tst_QWindow::isExposed() QTRY_VERIFY(window.received(QEvent::Expose) > 0); QTRY_VERIFY(window.isExposed()); -#ifndef Q_OS_WIN - // This is a top-level window so assuming it is completely exposed, the - // expose region must be (0, 0), (width, height). If this is not the case, - // the platform plugin is sending expose events with a region in an - // incorrect coordinate system. - QRect r = window.exposeRegion().boundingRect(); - r = QRect(window.mapToGlobal(r.topLeft()), r.size()); - QCOMPARE(r, window.geometry()); -#endif - window.hide(); QCoreApplication::processEvents();