platforms/drm: replace pointer to egl backend with QPointer

If the egl backend gets deleted this leaves a dangling pointer. In
order to prevent crashes with QPainter or EglStreams also don't try
to create dmabuf textures without a EglGbmBackend.
This commit is contained in:
Xaver Hugl 2021-05-19 19:27:04 +02:00
parent 39e2387f9f
commit 793cc5fa25
2 changed files with 7 additions and 7 deletions

View file

@ -648,13 +648,12 @@ QString DrmBackend::supportInformation() const
DmaBufTexture *DrmBackend::createDmaBufTexture(const QSize &size)
{
#if HAVE_GBM
// as the first GPU is assumed to always be the one used for scene rendering
// make sure we're on the right context:
m_gpus.at(0)->eglBackend()->makeCurrent();
return GbmDmaBuf::createBuffer(size, m_gpus.at(0)->gbmDevice());
#else
return nullptr;
if (primaryGpu()->eglBackend() && primaryGpu()->gbmDevice()) {
primaryGpu()->eglBackend()->makeCurrent();
return GbmDmaBuf::createBuffer(size, primaryGpu()->gbmDevice());
}
#endif
return nullptr;
}
DrmGpu *DrmBackend::primaryGpu() const

View file

@ -13,6 +13,7 @@
#include <qobject.h>
#include <QVector>
#include <QSocketNotifier>
#include <QPointer>
#include <epoxy/egl.h>
@ -116,7 +117,7 @@ private:
void tryAMS();
DrmBackend* const m_backend;
AbstractEglBackend *m_eglBackend;
QPointer<AbstractEglBackend> m_eglBackend;
const QString m_devNode;
QSize m_cursorSize;