From 914f083741e694092ee60a39d31f693d0a6dc734 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sat, 22 Jun 2024 16:50:53 +0200 Subject: [PATCH] client: properly release objects on destroy --- src/main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7ab8d4d..df3b510 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -871,6 +871,16 @@ void {}::onDestroyCalled() {{ IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL, IFACE_NAME + "_interface", IFACE_CLASS_NAME_CAMEL, IFACE_VTABLE_NAME, IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL); } else { + std::string DTOR_FUNC = ""; + + for (auto& rq : iface.requests) { + if (!rq.destructor) + continue; + + DTOR_FUNC = camelize("send_" + rq.name) + "()"; + break; + } + SOURCE += std::format(R"#( {}::{}(wl_resource* resource) {{ pResource = resource; @@ -883,10 +893,10 @@ void {}::onDestroyCalled() {{ {}::~{}() {{ if (!destroyed) - wl_proxy_destroy(pResource); + {}; }} )#", - IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL, IFACE_VTABLE_NAME, IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL); + IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL, IFACE_VTABLE_NAME, IFACE_CLASS_NAME_CAMEL, IFACE_CLASS_NAME_CAMEL, DTOR_FUNC); } for (auto& rq : (clientCode ? iface.events : iface.requests)) {