summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2017-08-28 12:58:55 +0200
committerJohan Helsing <johan.helsing@qt.io>2017-10-25 11:37:38 +0000
commit063299d8520ca5c944a596723e63e7654e712955 (patch)
treec8d609fee9fbdfb83f3792082214322a646997ca /src
parenta89d294a2e15995a707316608e6df0efc31b1857 (diff)
qtwaylandscanner: Remove globals when destroying wrappers
When globals are destroyed on the compositor side, send the "global_remove" event and set the resource implementation to nullptr so all further requests are ignored. This also adds a compositor test to see if outputs are removed when they are deleted. Change-Id: Ib77a4c3d4c2c93283a14ac20f5964e2ce08a1d38 Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qtwaylandscanner/qtwaylandscanner.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp
index ed36a1386..d6a83dbbc 100644
--- a/src/qtwaylandscanner/qtwaylandscanner.cpp
+++ b/src/qtwaylandscanner/qtwaylandscanner.cpp
@@ -504,6 +504,7 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf(" private:\n");
printf(" static void bind_func(struct ::wl_client *client, void *data, uint32_t version, uint32_t id);\n");
printf(" static void destroy_func(struct ::wl_resource *client_resource);\n");
+ printf(" static void display_destroy_func(struct ::wl_listener *listener, void *data);\n");
printf("\n");
printf(" Resource *bind(struct ::wl_client *client, uint32_t id, int version);\n");
printf(" Resource *bind(struct ::wl_resource *handle);\n");
@@ -527,6 +528,10 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf(" Resource *m_resource;\n");
printf(" struct ::wl_global *m_global;\n");
printf(" uint32_t m_globalVersion;\n");
+ printf(" struct DisplayDestroyedListener : ::wl_listener {\n");
+ printf(" %s *parent;\n", interfaceName);
+ printf(" };\n");
+ printf(" DisplayDestroyedListener m_displayDestroyedListener;\n");
printf(" };\n");
if (j < interfaces.size() - 1)
@@ -607,6 +612,13 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf(" %s::~%s()\n", interfaceName, interfaceName);
printf(" {\n");
+ printf(" for (auto resource : qAsConst(m_resource_map))\n");
+ printf(" wl_resource_set_implementation(resource->handle, nullptr, nullptr, nullptr);\n");
+ printf("\n");
+ printf(" if (m_global) {\n");
+ printf(" wl_global_destroy(m_global);\n");
+ printf(" wl_list_remove(&m_displayDestroyedListener.link);\n");
+ printf(" }\n");
printf(" }\n");
printf("\n");
@@ -642,6 +654,9 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf(" {\n");
printf(" m_global = wl_global_create(display, &::%s_interface, version, this, bind_func);\n", interfaceName);
printf(" m_globalVersion = version;\n");
+ printf(" m_displayDestroyedListener.notify = %s::display_destroy_func;\n", interfaceName);
+ printf(" m_displayDestroyedListener.parent = this;\n");
+ printf(" wl_display_add_destroy_listener(display, &m_displayDestroyedListener);\n");
printf(" }\n");
printf("\n");
@@ -674,6 +689,14 @@ void process(QXmlStreamReader &xml, const QByteArray &headerPath, const QByteArr
printf(" }\n");
printf("\n");
+ printf(" void %s::display_destroy_func(struct ::wl_listener *listener, void *data)\n", interfaceName);
+ printf(" {\n");
+ printf(" Q_UNUSED(data);\n");
+ printf(" %s *that = static_cast<%s::DisplayDestroyedListener *>(listener)->parent;\n", interfaceName, interfaceName);
+ printf(" that->m_global = nullptr;\n");
+ printf(" }\n");
+ printf("\n");
+
printf(" void %s::destroy_func(struct ::wl_resource *client_resource)\n", interfaceName);
printf(" {\n");
printf(" Resource *resource = Resource::fromResource(client_resource);\n");