summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2019-03-12 13:46:21 +0100
committerJohan Helsing <johan.helsing@qt.io>2019-03-14 12:13:21 +0000
commit489fedaa320a4941a9fc6a17df1a791c93270bb8 (patch)
tree5344ff7bf1146864fe0fa2ba22166e3e954649f9
parent7206b4e8b6e10f5623b19ca132f538066c96aab5 (diff)
Compositor: Call eglUnbindWaylandDisplayWL when destroying the compositor
If unbind is not called, some drivers may try to do cleanup that depends on a valid wl_display in eglTerminate. Arguably, this could/should also have been fixed in the affected drivers. There is a display_destroy signal that the driver should listen to, to avoid using dangling wl_display and wl_global pointers. However, by using eglUnbindWaylandDisplayWL we can force the cleanup to happen before wl_display_destroy. Which is what this patch does. Change-Id: Id9062de896b723838bcecac3902031e6b172a6de Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
-rw-r--r--src/compositor/compositor_api/qwaylandcompositor.cpp3
-rw-r--r--src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp8
2 files changed, 11 insertions, 0 deletions
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp
index 173b50ce..a0d69c52 100644
--- a/src/compositor/compositor_api/qwaylandcompositor.cpp
+++ b/src/compositor/compositor_api/qwaylandcompositor.cpp
@@ -243,6 +243,9 @@ QWaylandCompositorPrivate::~QWaylandCompositorPrivate()
delete data_device_manager;
#endif
+ // Some client buffer integrations need to clean up before the destroying the wl_display
+ client_buffer_integration.reset();
+
wl_display_destroy(display);
}
diff --git a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp
index 2cadf850..88dab2ab 100644
--- a/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp
+++ b/src/hardwareintegration/compositor/wayland-egl/waylandeglclientbufferintegration.cpp
@@ -186,6 +186,7 @@ public:
EGLDisplay egl_display = EGL_NO_DISPLAY;
bool valid = false;
bool display_bound = false;
+ ::wl_display *wlDisplay = nullptr;
QOffscreenSurface *offscreenSurface = nullptr;
QOpenGLContext *localContext = nullptr;
QVector<QOpenGLTexture *> orphanedTextures;
@@ -394,6 +395,12 @@ WaylandEglClientBufferIntegration::WaylandEglClientBufferIntegration()
WaylandEglClientBufferIntegration::~WaylandEglClientBufferIntegration()
{
WaylandEglClientBufferIntegrationPrivate::shuttingDown = true;
+ Q_D(WaylandEglClientBufferIntegration);
+ if (d->egl_unbind_wayland_display && d->display_bound) {
+ Q_ASSERT(d->wlDisplay);
+ if (!d->egl_unbind_wayland_display(d->egl_display, d->wlDisplay))
+ qWarning() << "Qt Wayland Compositor: eglUnbindWaylandDisplayWL failed";
+ }
}
void WaylandEglClientBufferIntegration::initializeHardware(struct wl_display *display)
@@ -450,6 +457,7 @@ void WaylandEglClientBufferIntegration::initializeHardware(struct wl_display *di
qWarning("QtCompositor: Could not bind Wayland display. Ignoring.");
}
}
+ d->wlDisplay = display;
}
d->funcs = new QEGLStreamConvenience;