Paste P635

Masterwork From Distant Lands
ActivePublic

Authored by davidedmundson on Sep 11 2020, 1:00 PM.
commit de5373e8d1f3b87f9d692652e76ac0535c394821
Author: David Edmundson <davidedmundson@kde.org>
Date: Sun Aug 23 01:05:49 2020 +0100
scanner_fix
Change-Id: Idae9ebd04bb38503c6bbe041ed64e81f92a27b7b
diff --git a/src/qtwaylandscanner/qtwaylandscanner.cpp b/src/qtwaylandscanner/qtwaylandscanner.cpp
index 3cecb5bc..409ea0ce 100644
--- a/src/qtwaylandscanner/qtwaylandscanner.cpp
+++ b/src/qtwaylandscanner/qtwaylandscanner.cpp
@@ -716,10 +716,13 @@ bool Scanner::process()
printf(" }\n");
printf("\n");
+ bool hasRequests = !interface.requests.empty();
+ QByteArray interfaceMember = hasRequests ? "&m_" + interface.name + "_interface" : QByteArray("nullptr");
+
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(" wl_resource_set_implementation(resource->handle, %s, nullptr, nullptr);\n", interfaceMember.constData());
printf("\n");
printf(" if (m_global) {\n");
printf(" wl_global_destroy(m_global);\n");
@@ -806,18 +809,15 @@ bool Scanner::process()
printf(" void %s::destroy_func(struct ::wl_resource *client_resource)\n", interfaceName);
printf(" {\n");
printf(" Resource *resource = Resource::fromResource(client_resource);\n");
- printf(" Q_ASSERT(resource);\n");
- printf(" %s *that = resource->%s_object;\n", interfaceName, interfaceNameStripped);
- printf(" that->m_resource_map.remove(resource->client(), resource);\n");
- printf(" that->%s_destroy_resource(resource);\n", interfaceNameStripped);
+ printf(" if (resource) {;\n");
+ printf(" %s *that = resource->%s_object;\n", interfaceName, interfaceNameStripped);
+ printf(" that->m_resource_map.remove(resource->client(), resource);\n");
+ printf(" that->%s_destroy_resource(resource);\n", interfaceNameStripped);
+ printf(" }");
printf(" delete resource;\n");
printf(" }\n");
printf("\n");
- bool hasRequests = !interface.requests.empty();
-
- QByteArray interfaceMember = hasRequests ? "&m_" + interface.name + "_interface" : QByteArray("nullptr");
-
//We should consider changing bind so that it doesn't special case id == 0
//and use function overloading instead. Jan do you have a lot of code dependent on this behavior?
printf(" %s::Resource *%s::bind(struct ::wl_client *client, uint32_t id, int version)\n", interfaceName, interfaceName);
@@ -883,6 +883,7 @@ bool Scanner::process()
printf(" {\n");
printf(" Q_UNUSED(client);\n");
printf(" Resource *r = Resource::fromResource(resource);\n");
+ printf(" if (!r) return;");
printf(" static_cast<%s *>(r->%s_object)->%s_%s(\n", interfaceName, interfaceNameStripped, interfaceNameStripped, e.name.constData());
printf(" r");
for (const WaylandArgument &a : e.arguments) {
davidedmundson edited the content of this paste. (Show Details)Sep 11 2020, 1:00 PM
davidedmundson changed the title of this paste from untitled to Masterwork From Distant Lands.