backends/drm: Handle failing to reopen drm node
Otherwise the drm backend will crash.
This commit is contained in:
parent
8934a31dad
commit
236baa63df
2 changed files with 10 additions and 3 deletions
|
@ -204,11 +204,16 @@ DrmGpu *DrmBackend::addGpu(const QString &fileName)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
DrmGpu *gpu = new DrmGpu(this, fileName, fd, buf.st_rdev);
|
||||
if (!gpu->graphicsBufferAllocator()) {
|
||||
delete gpu;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
qCDebug(KWIN_DRM, "adding GPU %s", qPrintable(fileName));
|
||||
m_gpus.push_back(std::make_unique<DrmGpu>(this, fileName, fd, buf.st_rdev));
|
||||
auto gpu = m_gpus.back().get();
|
||||
connect(gpu, &DrmGpu::outputAdded, this, &DrmBackend::addOutput);
|
||||
connect(gpu, &DrmGpu::outputRemoved, this, &DrmBackend::removeOutput);
|
||||
m_gpus.emplace_back(gpu);
|
||||
Q_EMIT gpuAdded(gpu);
|
||||
return gpu;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,9 @@ DrmGpu::DrmGpu(DrmBackend *backend, const QString &devNode, int fd, dev_t device
|
|||
|
||||
// Reopen the drm node to create a new GEM handle namespace.
|
||||
m_gbmFd = FileDescriptor{open(devNode.toLocal8Bit(), O_RDWR | O_CLOEXEC)};
|
||||
if (m_gbmFd.isValid()) {
|
||||
if (!m_gbmFd.isValid()) {
|
||||
qCCritical(KWIN_DRM) << "Failed to reopen" << devNode << "drm node, expect bad things to happen:" << strerror(errno);
|
||||
} else {
|
||||
drm_magic_t magic;
|
||||
drmGetMagic(m_gbmFd.get(), &magic);
|
||||
drmAuthMagic(m_fd, magic);
|
||||
|
|
Loading…
Reference in a new issue