screencast: Disable screencasting when a window closes

There were still some cases where we might have queried the window,
leading to a crash.

BUG: 469055
This commit is contained in:
Aleix Pol 2023-04-28 00:21:24 +02:00 committed by Aleix Pol Gonzalez
parent cf8b2195bb
commit 660ad887ee

View file

@ -313,7 +313,10 @@ ScreenCastStream::ScreenCastStream(ScreenCastSource *source, QObject *parent)
, m_source(source) , m_source(source)
, m_resolution(source->textureSize()) , m_resolution(source->textureSize())
{ {
connect(source, &ScreenCastSource::closed, this, &ScreenCastStream::stopStreaming); connect(source, &ScreenCastSource::closed, this, [this] {
m_streaming = false;
Q_EMIT stopStreaming();
});
pwStreamEvents.version = PW_VERSION_STREAM_EVENTS; pwStreamEvents.version = PW_VERSION_STREAM_EVENTS;
pwStreamEvents.add_buffer = &ScreenCastStream::onStreamAddBuffer; pwStreamEvents.add_buffer = &ScreenCastStream::onStreamAddBuffer;