QRhiGles2: Skip GL cleanup on context loss

We are getting errors such as

  WebGL: INVALID_OPERATION: delete: object does not
  belong to this context

Normally, QRhiGles2::destroy() should delete/free all
GL resources. However if the GL context is lost then
there is not much we can do.

Task-number: QTBUG-120138
Change-Id: I6d00b10d72b7f7240499ceff0d002b88104009a0
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
This commit is contained in:
Morten Sørvig 2024-07-19 13:59:40 +02:00
parent b57fac818b
commit a47f6fde87

View File

@ -1118,23 +1118,24 @@ void QRhiGles2::destroy()
if (!f) if (!f)
return; return;
ensureContext(); if (ensureContext()) {
executeDeferredReleases(); executeDeferredReleases();
if (ofr.tsQueries[0]) { if (ofr.tsQueries[0]) {
f->glDeleteQueries(2, ofr.tsQueries); f->glDeleteQueries(2, ofr.tsQueries);
ofr.tsQueries[0] = ofr.tsQueries[1] = 0; ofr.tsQueries[0] = ofr.tsQueries[1] = 0;
}
if (vao) {
f->glDeleteVertexArrays(1, &vao);
vao = 0;
}
for (uint shader : m_shaderCache)
f->glDeleteShader(shader);
m_shaderCache.clear();
} }
if (vao) {
f->glDeleteVertexArrays(1, &vao);
vao = 0;
}
for (uint shader : m_shaderCache)
f->glDeleteShader(shader);
m_shaderCache.clear();
if (!importedContext) { if (!importedContext) {
delete ctx; delete ctx;
ctx = nullptr; ctx = nullptr;