backends/drm: Fix a crash in DrmGpu::releaseBuffers()

Currently, the code assumes that the primary and the cursor layers are
always present. However, it's not guaranteed if the render backend cannot
be recreated. Specifically:

- the Compositor destroys the EglGbmBackend. The egl gbm backend, in its
  turn, resets the primary and the cursor layers to null
- the Compositor tries to create the EglGbmBackend but that fails so it
  is destroyed. EglGbmBackend::~EglGbmBackend() calls DrmGpu::releaseBuffers(),
  but it hits an unexpected null primary layer.

Normally, the primary and the cursor layers would be created when the
Compositor successfully creates the WorkspaceScene. Since the RenderBackend
fails to initialize, the WorkspaceScene is not created and the DrmGpu
doesn't recreate the layers.
This commit is contained in:
Vlad Zahorodnii 2024-07-22 13:18:25 +03:00
parent 59699402ad
commit 2ec45f33d1

View file

@ -806,8 +806,12 @@ void DrmGpu::releaseBuffers()
crtc->releaseCurrentBuffer();
}
for (const auto &pipeline : std::as_const(m_pipelines)) {
pipeline->primaryLayer()->releaseBuffers();
pipeline->cursorLayer()->releaseBuffers();
if (DrmPipelineLayer *layer = pipeline->primaryLayer()) {
layer->releaseBuffers();
}
if (DrmPipelineLayer *layer = pipeline->cursorLayer()) {
layer->releaseBuffers();
}
}
}