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 e0eb2818fa.
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.5 6.6 6.7
Change-Id: I5c0747da10f0275b77f56be32690d796fa48cdb4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
parent
d44629d677
commit
6cb497c157
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ public:
|
|||
QPaintDeviceWindowPrivate();
|
||||
~QPaintDeviceWindowPrivate() override;
|
||||
|
||||
virtual void handleResizeEvent() {}
|
||||
|
||||
virtual void beginPaint(const QRegion ®ion)
|
||||
{
|
||||
Q_UNUSED(region);
|
||||
|
|
|
|||
|
|
@ -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 ®ion) 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue