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
This commit is contained in:
Aleix Pol 2021-09-28 17:56:51 +02:00 committed by Aleix Pol Gonzalez
parent de674e087a
commit 9bda050d84

View file

@ -75,6 +75,11 @@ private:
return; return;
} }
QSharedPointer<GLTexture> frameTexture(m_toplevel->effectWindow()->sceneWindow()->windowTexture()); QSharedPointer<GLTexture> 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(); const bool wasYInverted = frameTexture->isYInverted();
frameTexture->setYInverted(false); frameTexture->setYInverted(false);
@ -118,6 +123,10 @@ void ScreencastManager::streamOutput(KWaylandServer::ScreencastStreamV1Interface
auto bufferToStream = [streamOutput, stream] (const QRegion &damagedRegion) { auto bufferToStream = [streamOutput, stream] (const QRegion &damagedRegion) {
auto scene = Compositor::self()->scene(); auto scene = Compositor::self()->scene();
auto texture = scene->textureForOutput(streamOutput); 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 QRect frame({}, streamOutput->modeSize());
const QRegion region = damagedRegion.isEmpty() || streamOutput->pixelSize() != streamOutput->modeSize() ? frame : damagedRegion.translated(-streamOutput->geometry().topLeft()).intersected(frame); const QRegion region = damagedRegion.isEmpty() || streamOutput->pixelSize() != streamOutput->modeSize() ? frame : damagedRegion.translated(-streamOutput->geometry().topLeft()).intersected(frame);