fix memory leaks, and reference of uninitialized value

This commit is contained in:
falsycat 2022-08-28 19:45:12 +09:00
parent feb481f00f
commit 6a4ddb1642
6 changed files with 12 additions and 9 deletions

View File

@ -170,7 +170,7 @@ struct Timeline {
// volatile params
enum {kRoot, kHeader, kBody, kItem} frame_state_ = kRoot;
uint64_t len_;
uint64_t len_ = 0;
ImVec2 scroll_size_;
bool scroll_x_to_mouse_;
bool scroll_y_to_mouse_;

View File

@ -143,8 +143,10 @@ class InlineNode::Lambda final : public nf7::Node::Lambda,
th->Install(log_);
th_.emplace_back(th);
auto ctx = std::make_shared<nf7::GenericContext>(*file_);
auto p = std::make_pair(std::string {k}, std::move(v));
ljq->Push(self, [self, this, ljq, caller, th, scr = std::move(scr), p = std::move(p)](auto L) {
ljq->Push(self, [this, ctx, ljq, caller, th, scr = std::move(scr), p = std::move(p)](auto L) {
auto thL = th->Init(L);
// push function
@ -154,7 +156,7 @@ class InlineNode::Lambda final : public nf7::Node::Lambda,
return;
}
lua_pushvalue(thL, -1);
func_.emplace(self, ljq, thL);
func_.emplace(ctx, ljq, thL);
} else {
if (!func_) {
log_->Error("last cache is broken");
@ -177,7 +179,7 @@ class InlineNode::Lambda final : public nf7::Node::Lambda,
} else {
lua_createtable(thL, 0, 0);
lua_pushvalue(thL, -1);
ctxtable_.emplace(self, ljq, thL);
ctxtable_.emplace(ctx, ljq, thL);
}
// start function

View File

@ -211,7 +211,8 @@ class Node::Lambda final : public nf7::Node::Lambda,
th->Install(log_);
th_.emplace_back(th);
ljq->Push(self, [this, self, ljq, k = std::move(k), v = std::move(v), caller, func, th](auto L) mutable {
auto ctx = std::make_shared<nf7::GenericContext>(env(), initiator());
ljq->Push(self, [this, ctx, ljq, k = std::move(k), v = std::move(v), caller, func, th](auto L) mutable {
auto thL = th->Init(L);
func->PushSelf(thL);
@ -226,7 +227,7 @@ class Node::Lambda final : public nf7::Node::Lambda,
if (!ctxtable_) {
lua_createtable(thL, 0, 0);
lua_pushvalue(thL, -1);
ctxtable_.emplace(shared_from_this(), ljq, thL);
ctxtable_.emplace(ctx, ljq, thL);
} else {
ctxtable_->PushSelf(thL);
}

View File

@ -204,7 +204,7 @@ class Ref final : public nf7::FileBase, public nf7::Node {
watcher_.emplace(env());
watcher_->AddHandler(nf7::File::Event::kUpdate, [this](auto&) { Touch(); });
watcher_->Watch(id);
} catch (nf7::File::NotFoundException&) {
} catch (nf7::Exception&) {
}
};

View File

@ -136,7 +136,7 @@ class TL final : public nf7::FileBase, public nf7::DirItem, public nf7::Node {
uint64_t action_layer_;
// permanentized params
uint64_t cursor_;
uint64_t cursor_ = 0;
std::vector<std::unique_ptr<Layer>> layers_;
std::vector<std::string> seq_inputs_;

View File

@ -124,7 +124,7 @@ class Curve final : public nf7::File,
// GUI parameters
std::unordered_set<uint64_t> selected_;
bool last_action_moved_;
bool last_action_moved_ = false;
void AddPoint(const ImVec2& pos) noexcept {