Use workspaceLayer as context object

Otherwise the connection isn't severed when the layer is destroyed,
leading to crashes when screen resolution changes.

We don't actually need `this` to access `workspace()`, and we have
a guarded `output` as sender in the other case.
This commit is contained in:
Kai Uwe Broulik 2022-03-04 22:18:51 +01:00
parent b11499d95e
commit 32daab286d

View file

@ -365,7 +365,7 @@ void Compositor::startupWithWorkspace()
auto workspaceLayer = new RenderLayer(outputs.constFirst()->renderLoop()); auto workspaceLayer = new RenderLayer(outputs.constFirst()->renderLoop());
workspaceLayer->setDelegate(new SceneDelegate(m_scene)); workspaceLayer->setDelegate(new SceneDelegate(m_scene));
workspaceLayer->setGeometry(workspace()->geometry()); workspaceLayer->setGeometry(workspace()->geometry());
connect(workspace(), &Workspace::geometryChanged, this, [workspaceLayer]() { connect(workspace(), &Workspace::geometryChanged, workspaceLayer, [workspaceLayer]() {
workspaceLayer->setGeometry(workspace()->geometry()); workspaceLayer->setGeometry(workspace()->geometry());
}); });
addSuperLayer(workspaceLayer); addSuperLayer(workspaceLayer);
@ -424,7 +424,7 @@ void Compositor::addOutput(AbstractOutput *output)
auto workspaceLayer = new RenderLayer(output->renderLoop()); auto workspaceLayer = new RenderLayer(output->renderLoop());
workspaceLayer->setDelegate(new SceneDelegate(m_scene, output)); workspaceLayer->setDelegate(new SceneDelegate(m_scene, output));
workspaceLayer->setGeometry(output->geometry()); workspaceLayer->setGeometry(output->geometry());
connect(output, &AbstractOutput::geometryChanged, this, [output, workspaceLayer]() { connect(output, &AbstractOutput::geometryChanged, workspaceLayer, [output, workspaceLayer]() {
workspaceLayer->setGeometry(output->geometry()); workspaceLayer->setGeometry(output->geometry());
}); });