Make sure the correct context is current when invoking resizeGL

After the 6.4 changes for QRhi-based compositing in widgets there
is now a good chance that a different context is current after
recreateFbo in case it actually created a new texture and fbo.
This is not great if we immediately call resizeGL() afterwards
since the contract for the reimplementable functions is that
the QOpenGLWidget's context is current. Make sure this contract
is followed.

Fixes: QTBUG-103319
Change-Id: I59a5fa9500df34b86787927e1114d0a80297678a
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2022-05-16 12:20:45 +02:00
parent 34defa095a
commit ba7a3b8d4a

View File

@ -1264,6 +1264,9 @@ void QOpenGLWidget::resizeEvent(QResizeEvent *e)
return; return;
d->recreateFbo(); d->recreateFbo();
// Make sure our own context is current before invoking user overrides. If
// the fbo was recreated then there's a chance something else is current now.
makeCurrent();
resizeGL(width(), height()); resizeGL(width(), height());
d->sendPaintEvent(QRect(QPoint(0, 0), size())); d->sendPaintEvent(QRect(QPoint(0, 0), size()));
} }