Make sure window thumbnails and Qt Quick resources are destroyed properly

Drops the doneCurrent as it was preventing proper cleanUp
because no context was current when textures were deleted.
Also avoid manipulating the context when Qt has the current
one, as various Qt classes have guards around their cleanup
handlers which rely on a current Qt context.
Despite the comment the order of render control and view destruction
needs to be switched as the QQuickWindow destructor calls into
the render control to notify if of window destruction.
BUG:478770
BUG:479846
FIXED-IN:6.0
This commit is contained in:
David Redondo 2024-01-16 13:28:01 +01:00
parent 3dd18a543b
commit 203c4998bc
2 changed files with 10 additions and 11 deletions

View file

@ -159,9 +159,8 @@ OffscreenQuickView::~OffscreenQuickView()
d->m_glcontext->makeCurrent(d->m_offscreenSurface.get());
}
// Always delete render control first.
d->m_renderControl.reset();
d->m_view.reset();
d->m_renderControl.reset();
}
bool OffscreenQuickView::automaticRepaint() const

View file

@ -22,6 +22,7 @@
#include "opengl/gltexture.h"
#include <QOpenGLContext>
#include <QQuickWindow>
#include <QRunnable>
#include <QSGImageNode>
@ -57,8 +58,9 @@ WindowThumbnailSource::~WindowThumbnailSource()
if (!m_offscreenTexture) {
return;
}
if (WorkspaceScene *scene = Compositor::self()->scene()) {
scene->makeOpenGLContextCurrent();
if (!QOpenGLContext::currentContext()) {
Compositor::self()->scene()->makeOpenGLContextCurrent();
}
m_offscreenTarget.reset();
m_offscreenTexture.reset();
@ -66,8 +68,6 @@ WindowThumbnailSource::~WindowThumbnailSource()
glDeleteSync(m_acquireFence);
m_acquireFence = 0;
}
scene->doneOpenGLContextCurrent();
}
}
std::shared_ptr<WindowThumbnailSource> WindowThumbnailSource::getOrCreate(QQuickWindow *window, Window *handle)