From 9bda050d84ed493cbe429116b32739a72e3ce994 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 28 Sep 2021 17:56:51 +0200 Subject: [PATCH] screencasting: Do not crash when the platform cannot provide textures When using the QPainter backend, we will be getting null textures. Just ignore these as the backend isn't all that important. BUG: 442711 --- src/plugins/screencast/screencastmanager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/screencast/screencastmanager.cpp b/src/plugins/screencast/screencastmanager.cpp index 9cbe2a5779..d5a6032711 100644 --- a/src/plugins/screencast/screencastmanager.cpp +++ b/src/plugins/screencast/screencastmanager.cpp @@ -75,6 +75,11 @@ private: return; } QSharedPointer frameTexture(m_toplevel->effectWindow()->sceneWindow()->windowTexture()); + if (!frameTexture) { + // Some backends will return no-op because textures aren't really supported there + return; + } + const bool wasYInverted = frameTexture->isYInverted(); frameTexture->setYInverted(false); @@ -118,6 +123,10 @@ void ScreencastManager::streamOutput(KWaylandServer::ScreencastStreamV1Interface auto bufferToStream = [streamOutput, stream] (const QRegion &damagedRegion) { auto scene = Compositor::self()->scene(); auto texture = scene->textureForOutput(streamOutput); + if (!texture) { + // Some backends will return no-op because textures aren't really supported there + return; + } const QRect frame({}, streamOutput->modeSize()); const QRegion region = damagedRegion.isEmpty() || streamOutput->pixelSize() != streamOutput->modeSize() ? frame : damagedRegion.translated(-streamOutput->geometry().topLeft()).intersected(frame);