Commit 5bca0588 authored by David Edmundson's avatar David Edmundson
Browse files

Fix DRM EGL crash regression

In 47343fb8 we made GBM buffer shared.

What we wanted to do was:
Unbox the shared_pointer<GBMSurface> to give us a GBMSurface* object
Call the gbm_surface*() on that operator
Then cast that to a void* for eglCreatePlatformWindowSurfaceEXT

What we did:
Cast the std::shared_ptr<GBMSurface> to a gbm_surface*  then cast that
to void*.
This is just a garbage value and it crashes in Mesa when we do our first

I've replaced that with an explicit method then we can use shared_ptr's
-> operator rather than get() which does the right thing in a readable

Test Plan:
It crashed after rebasing to master (for Aleix too)
No longer crashes

Reviewers: #plasma

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision:
parent d6a906da
......@@ -78,7 +78,7 @@ private Q_SLOTS:
void GbmSurfaceTest::testCreate()
GbmSurface surface(nullptr, 2, 3, 4, 5);
gbm_surface *native = surface;
gbm_surface *native = surface.surface();
QCOMPARE(native->width, 2u);
QCOMPARE(native->height, 3u);
......@@ -91,7 +91,7 @@ void GbmSurfaceTest::testCreateFailure()
gbm_device dev{true};
GbmSurface surface(&dev, 2, 3, 4, 5);
gbm_surface *native = surface;
gbm_surface *native = surface.surface();
......@@ -162,7 +162,7 @@ void EglGbmBackend::createOutput(DrmOutput *drmOutput)
qCCritical(KWIN_DRM) << "Create gbm surface failed";
o.eglSurface = eglCreatePlatformWindowSurfaceEXT(eglDisplay(), config(), (void *)((gbm_surface*)o.gbmSurface.get()), nullptr);
o.eglSurface = eglCreatePlatformWindowSurfaceEXT(eglDisplay(), config(), (void *)(o.gbmSurface->surface()), nullptr);
if (o.eglSurface == EGL_NO_SURFACE) {
qCCritical(KWIN_DRM) << "Create Window Surface failed";
......@@ -42,7 +42,7 @@ public:
return m_surface != nullptr;
operator gbm_surface*() const {
gbm_surface* surface() const {
return m_surface;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment