QOpenGLWidget: correct the lifetime of the wrapper texture objects

If the QOpenGLFramebufferObject (which owns the OpenGL texture object)
is destroyed, the wrapper QRhiTexture must be destroyed too.

This surfaced with WebAssembly for some reason, likely due to an event
(most likely resize) sending pattern that is different from other
platforms. Sending more resizes likely triggers another recreateFbos()
call which, until now, did not correctly dropped the wrapper
QRhiTextures so those continued to refer to the now-destroyed texture
IDs.

Task-number: QTBUG-111304
Change-Id: Ieed9a11c5c28da0fee497107ebe88da9eb5f45a8
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit 2b908ba8f40924abded15681cf3b4af6056c3050)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Laszlo Agocs 2023-04-17 13:46:10 +02:00 committed by Qt Cherry-pick Bot
parent 9fbc5f1c73
commit 6dc44dd127

View File

@ -691,8 +691,6 @@ void QOpenGLWidgetPrivate::reset()
destroyFbos();
resetRhiDependentResources();
if (initialized)
q->doneCurrent();
@ -1016,6 +1014,8 @@ void QOpenGLWidgetPrivate::destroyFbos()
fbos[QOpenGLWidget::RightBuffer] = nullptr;
delete resolvedFbos[QOpenGLWidget::RightBuffer];
resolvedFbos[QOpenGLWidget::RightBuffer] = nullptr;
resetRhiDependentResources();
}
QImage QOpenGLWidgetPrivate::grabFramebuffer()