Don't rely on QRasterWindow::resizeEvent for marking window dirty

The de-virtualization gotcha might result in client code not calling
QRasterWindow::resizeEvent, which we use for dirty state management
after e0eb2818face4ffb7dafd87464f355d4654b7be0.

In practice this wasn't an issue, because QPaintDeviceWindow handles
paint events by calling markWindowAsDirty first, but we should not
rely on this.

Instead plumb the resize event to QPaintDeviceWindowPrivate, which
QRasterWindow implements and can override the behavior of.

Pick-to: 6.6 6.5
Change-Id: I5c0747da10f0275b77f56be32690d796fa48cdb4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6cb497c1570ee427460962b2c0abe3b6dd8c4ae6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-01-25 14:58:39 +01:00 committed by Qt Cherry-pick Bot
parent 3e563542b3
commit 527b5f6ff4
3 changed files with 11 additions and 3 deletions

View File

@ -171,6 +171,8 @@ bool QPaintDeviceWindow::event(QEvent *event)
auto region = QRect(QPoint(0, 0), size());
d->doFlush(region); // Will end up calling paintEvent
return true;
} else if (event->type() == QEvent::Resize) {
d->handleResizeEvent();
}
return QWindow::event(event);

View File

@ -31,6 +31,8 @@ public:
QPaintDeviceWindowPrivate();
~QPaintDeviceWindowPrivate() override;
virtual void handleResizeEvent() {}
virtual void beginPaint(const QRegion &region)
{
Q_UNUSED(region);

View File

@ -34,6 +34,13 @@ class QRasterWindowPrivate : public QPaintDeviceWindowPrivate
{
Q_DECLARE_PUBLIC(QRasterWindow)
public:
void handleResizeEvent() override
{
Q_Q(QRasterWindow);
if (backingstore->size() != q->size())
markWindowAsDirty();
}
void beginPaint(const QRegion &region) override
{
Q_Q(QRasterWindow);
@ -103,9 +110,6 @@ QPaintDevice *QRasterWindow::redirected(QPoint *) const
void QRasterWindow::resizeEvent(QResizeEvent *)
{
Q_D(QRasterWindow);
if (d->backingstore->size() != size())
d->markWindowAsDirty();
}
QT_END_NAMESPACE