浏览代码

small bug fix

Willi Zschiebsch 4 年之前
父节点
当前提交
4b8a184f03
共有 2 个文件被更改,包括 29 次插入14 次删除
  1. 2 2
      lib/src/ModuleBase.cpp
  2. 27 12
      lib/src/ProcessorBase.cpp

+ 2 - 2
lib/src/ModuleBase.cpp

@@ -111,11 +111,11 @@ namespace mdd {
         }
         jit = jconfig.find("appendix");
         if (jit != jconfig.end()) {
-            setAppendix(jit.value()["value"].get<int>());
+            setAppendix(jit.value().get<int>());
         }
         jit = jconfig.find("key");
         if (jit != jconfig.end()) {
-            key = jit.value()["value"].get<std::string>();
+            key = jit.value().get<std::string>();
         }
         return res;
     }

+ 27 - 12
lib/src/ProcessorBase.cpp

@@ -384,7 +384,7 @@ namespace mdd{
                 json jout = jcon["output"];
                 IModule::Ptr module_out_ptr = getModule(jout);
                 IOutput::Ptr out_ptr = nullptr;
-                std::string id = jout["name"].get<std::string>() + std::to_string(jout["appendix"].get<int>());
+                std::string id = jout["key"].get<std::string>() + std::to_string(jout["appendix"].get<int>());
                 for (size_t i = 0; i < module_out_ptr->getNumOutputs(); i++)
                 {
                     auto out = module_out_ptr->getOutput(i);
@@ -398,7 +398,7 @@ namespace mdd{
                 {
                     IModule::Ptr module_in_ptr = getModule(jin);
                     IInput::Ptr in_ptr = nullptr;
-                    std::string id = jin["name"].get<std::string>() + std::to_string(jin["appendix"].get<int>());
+                    std::string id = jin["key"].get<std::string>() + std::to_string(jin["appendix"].get<int>());
                     for (size_t i = 0; i < module_in_ptr->getNumInputs(); i++)
                     {
                         auto in = module_in_ptr->getInput(i);
@@ -529,19 +529,16 @@ namespace mdd{
         {
             if (auto module_ptr = mod)
             {
-                for (size_t j = 0; j < module_ptr->getNumOutputs(); j++)
+                auto input_connections = module_ptr->getOutput(0)->getConnections();
+                if (!input_connections.empty())
                 {
-                    auto input_connections = module_ptr->getOutput(j)->getConnections();
-                    if (!input_connections.empty())
+                    json connect;
+                    connect["output"] = module_ptr->getOutput(0)->getIdentifier();
+                    for (size_t k = 0; k < input_connections.size(); k++)
                     {
-                        json connect;
-                        connect["output"] = module_ptr->getOutput(j)->getIdentifier();
-                        for (size_t k = 0; k < input_connections.size(); k++)
-                        {
-                            connect["inputs"].push_back(input_connections[k]->getIdentifier());
-                        }
-                        ret["connections"].push_back(connect);
+                        connect["inputs"].push_back(input_connections[k]->getIdentifier());
                     }
+                    ret["connections"].push_back(connect);
                 }
             }
         }
@@ -736,6 +733,24 @@ namespace mdd{
                 break;
             }
         }
+        if (module_ptr == nullptr)
+        {
+            for (auto& module : inputs) {
+                if (module->getID() == sid) {
+                    module_ptr = module;
+                    break;
+                }
+            }
+        }
+        if (module_ptr == nullptr)
+        {
+            for (auto& module : outputs) {
+                if (module->getID() == sid) {
+                    module_ptr = module;
+                    break;
+                }
+            }
+        }
         
         if (module_ptr != nullptr)
         {