backends/drm: don't crash if importing a texture fails

CCBUG: 456500
This commit is contained in:
Xaver Hugl 2022-07-13 21:51:22 +02:00
parent c8c1b05661
commit 636b411b31

View file

@ -647,7 +647,14 @@ std::shared_ptr<DmaBufTexture> DrmBackend::createDmaBufTexture(const QSize &size
gbm_bo_destroy(bo); gbm_bo_destroy(bo);
const auto eglBackend = static_cast<EglGbmBackend *>(m_renderBackend); const auto eglBackend = static_cast<EglGbmBackend *>(m_renderBackend);
eglBackend->makeCurrent(); eglBackend->makeCurrent();
return std::make_shared<DmaBufTexture>(eglBackend->importDmaBufAsTexture(attributes), attributes); if (auto texture = eglBackend->importDmaBufAsTexture(attributes)) {
return std::make_shared<DmaBufTexture>(texture, attributes);
} else {
for (int i = 0; i < attributes.planeCount; ++i) {
::close(attributes.fd[i]);
}
return nullptr;
}
} }
DrmGpu *DrmBackend::primaryGpu() const DrmGpu *DrmBackend::primaryGpu() const