Fix DRM EGL crash regression

Summary:
In 47343fb 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
paint.

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
way.

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: https://phabricator.kde.org/D8251
This commit is contained in:
David Edmundson 2017-10-11 20:03:07 +02:00
parent 031e1f323f
commit 3d619c995b
3 changed files with 4 additions and 4 deletions

View file

@ -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();
QVERIFY(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);
QVERIFY(!surface);
gbm_surface *native = surface;
gbm_surface *native = surface.surface();
QVERIFY(!native);
}

View file

@ -162,7 +162,7 @@ void EglGbmBackend::createOutput(DrmOutput *drmOutput)
qCCritical(KWIN_DRM) << "Create gbm surface failed";
return;
}
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";
o.gbmSurface.reset();

View file

@ -42,7 +42,7 @@ public:
return m_surface != nullptr;
}
operator gbm_surface*() const {
gbm_surface* surface() const {
return m_surface;
}