client: properly release objects on destroy

This commit is contained in:
Vaxry 2024-06-22 16:50:53 +02:00
parent 1413398dca
commit 914f083741

View file

@ -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)) {