Skip to content

Commit

Permalink
client: properly release objects on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Jun 22, 2024
1 parent 1413398 commit 914f083
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down

0 comments on commit 914f083

Please sign in to comment.