fix an issue that node sockets can be duplicated
This commit is contained in:
@@ -267,6 +267,14 @@ try {
|
||||
auto new_inputs = yaml["inputs"] .as<std::vector<std::string>>();
|
||||
auto new_outputs = yaml["outputs"].as<std::vector<std::string>>();
|
||||
auto new_script = yaml["script"].as<std::string>();
|
||||
|
||||
if (nf7::util::Uniq(new_inputs) > 0) {
|
||||
throw nf7::Exception {"duplicated inputs"};
|
||||
}
|
||||
if (nf7::util::Uniq(new_outputs) > 0) {
|
||||
throw nf7::Exception {"duplicated outputs"};
|
||||
}
|
||||
|
||||
inputs = std::move(new_inputs);
|
||||
outputs = std::move(new_outputs);
|
||||
script = std::move(new_script);
|
||||
|
@@ -35,6 +35,7 @@
|
||||
#include "common/nfile_watcher.hh"
|
||||
#include "common/node.hh"
|
||||
#include "common/ptr_selector.hh"
|
||||
#include "common/util_algorithm.hh"
|
||||
#include "common/yas_std_filesystem.hh"
|
||||
|
||||
|
||||
@@ -232,10 +233,16 @@ nf7::Future<std::shared_ptr<LuaNode::Meta>> LuaNode::Build() noexcept {
|
||||
|
||||
lua_getfield(L, 1, "inputs");
|
||||
nf7::luajit::ToStringList(L, ret->inputs, -1);
|
||||
if (nf7::util::Uniq(ret->inputs) > 0) {
|
||||
throw nf7::Exception {"duplicated inputs"};
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, 1, "outputs");
|
||||
nf7::luajit::ToStringList(L, ret->outputs, -1);
|
||||
if (nf7::util::Uniq(ret->outputs)) {
|
||||
throw nf7::Exception {"duplicated outputs"};
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, 1, "lambda");
|
||||
|
Reference in New Issue
Block a user