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>
This commit is contained in:
parent
b90c278ed8
commit
80f167fbc4
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user