fix lambda leaks
This commit is contained in:
parent
63dd28ab76
commit
881704fc49
@ -77,8 +77,7 @@ class LuaContext::Queue final : public nf7::luajit::Queue,
|
||||
~Queue() noexcept {
|
||||
th_->Push(
|
||||
std::make_shared<nf7::GenericContext>(*env_, 0, "deleting lua_State"),
|
||||
[L = L](auto) { lua_close(L); }
|
||||
);
|
||||
[L = L](auto) { lua_close(L); });
|
||||
}
|
||||
Queue(const Queue&) = delete;
|
||||
Queue(Queue&&) = delete;
|
||||
|
@ -882,6 +882,7 @@ void Network::PostHandle(const Event& ev) noexcept {
|
||||
break;
|
||||
case Event::kRemove:
|
||||
for (const auto& item : items_) item->Detach();
|
||||
AttachLambda(nullptr);
|
||||
break;
|
||||
case Event::kUpdate:
|
||||
break;
|
||||
|
@ -65,8 +65,7 @@ class Singleton final : public nf7::FileBase,
|
||||
nf7::DirItem::kTooltip),
|
||||
nf7::GenericConfig(mem_),
|
||||
nf7::Node(nf7::Node::kNone),
|
||||
life_(*this), log_(*this), mem_(*this, std::move(d)),
|
||||
shared_la_(std::make_shared<Singleton::SharedLambda>(*this)) {
|
||||
life_(*this), log_(*this), mem_(*this, std::move(d)) {
|
||||
}
|
||||
|
||||
Singleton(nf7::Deserializer& ar) : Singleton(ar.env()) {
|
||||
@ -88,6 +87,7 @@ class Singleton final : public nf7::FileBase,
|
||||
return {};
|
||||
}
|
||||
|
||||
void PostHandle(const nf7::File::Event&) noexcept override;
|
||||
void PostUpdate() noexcept override {
|
||||
la_.erase(
|
||||
std::remove_if(
|
||||
@ -207,6 +207,20 @@ std::shared_ptr<nf7::Node::Lambda> Singleton::CreateLambda(
|
||||
}
|
||||
|
||||
|
||||
void Singleton::PostHandle(const nf7::File::Event& e) noexcept {
|
||||
switch (e.type) {
|
||||
case nf7::File::Event::kAdd:
|
||||
shared_la_ = std::make_shared<SharedLambda>(*this);
|
||||
return;
|
||||
case nf7::File::Event::kRemove:
|
||||
shared_la_->Abort();
|
||||
shared_la_ = nullptr;
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Singleton::UpdateMenu() noexcept {
|
||||
if (ImGui::MenuItem("drop current lambda")) {
|
||||
shared_la_->Abort();
|
||||
|
Loading…
x
Reference in New Issue
Block a user