OpenGL renderer: restore surface on context when shutting down


When using a QQuickWidget and Qt3D, on shutdown and assert occurs.
This is the result of the QQuickWidget expecting the surface on the context
to be its own internal surface after the QQuickRenderControl has been
invalidated.

This conflict with what Qt3D does on shutdown as it makes the context current
on its own internal offscreen surface on shutdown.

Therefore, to fix this issue, we record the surface in use before Qt3D shuts
down and we make the context current on it after Qt3D has shutdown.

Arguably, the fix should really go in QQuickWidgetPrivate::invalidateRenderControl
where the QQuickWidget should check that the current surface is indeed the one
it expects and set it accordingly.

Change-Id: I534dc330a30a2ad5d17a6416715d03206ef4b1c9
Pick-to: 6.2 5.15
Reviewed-by: Mike Krus <mike.krus@kdab.com>
commit559d77cacf7a3f6a29d3debec6d61a2ef8a59dc9
parentc71b73e8bc809cb23c9f66180e57eeef61dbd200
authorPaul Lemire <paul.lemire@kdab.com>
committerPaul Lemire <paul.lemire@kdab.com>
commit timeTue, 30 Nov 2021 10:40:28 +0100