Guard against null compositor in thumbnail item

If compositing is disabled, compositor will be null.

We hit a path where we could destroyOffscreenTexture when the
compositing is disabled then again when the Thumbnail is destroyed. In
this case we query Compositor::self()->scene() and crash.
This commit is contained in:
David Edmundson 2021-07-01 12:38:57 +01:00
parent f53cf9d71e
commit 893f95eed8

View file

@ -145,6 +145,9 @@ QSGTextureProvider *ThumbnailItemBase::textureProvider() const
void ThumbnailItemBase::handleCompositingToggled()
{
if (!Compositor::self()) {
return;
}
Scene *scene = Compositor::self()->scene();
if (scene && scene->compositingType() == OpenGLCompositing) {
connect(scene, &Scene::frameRendered, this, &ThumbnailItemBase::updateOffscreenTexture);
@ -167,6 +170,9 @@ void ThumbnailItemBase::setSourceSize(const QSize &sourceSize)
void ThumbnailItemBase::destroyOffscreenTexture()
{
if (!Compositor::self()) {
return;
}
Scene *scene = Compositor::self()->scene();
if (!scene || scene->compositingType() != OpenGLCompositing) {
return;