@@ -84,7 +84,7 @@ NetworkEditorController::NetworkEditorController(ModuleFactoryHandle mf, ModuleS
8484#endif
8585}
8686
87- NetworkEditorController::NetworkEditorController (SCIRun::Dataflow::Networks:: NetworkHandle network, ExecutionStrategyFactoryHandle executorFactory, NetworkEditorSerializationManager* nesm)
87+ NetworkEditorController::NetworkEditorController (NetworkHandle network, ExecutionStrategyFactoryHandle executorFactory, NetworkEditorSerializationManager* nesm)
8888 : theNetwork_(network), executorFactory_(executorFactory), serializationManager_(nesm),
8989 signalSwitch_(true )
9090{
@@ -314,14 +314,19 @@ ModuleHandle NetworkEditorController::connectNewModule(const PortDescriptionInte
314314 if (portToConnectUponInsertion)
315315 {
316316 std::cout << " I CAN REQUEST ANOTHER CONNECTION HERE: first port is output, second is " << portToConnectUponInsertion->isInput () << std::endl;
317- auto fromPort = std::find_if (newMod->outputPorts ().begin (), newMod->outputPorts ().end (), [portToConnectUponInsertion](OutputPortHandle out) { return out->get_typename () == portToConnectUponInsertion->get_typename (); });
318- if (fromPort != newMod->outputPorts ().end ())
317+ auto oports = newMod->outputPorts ();
318+ auto fromPort = std::find_if (oports.begin (), oports.end (), [portToConnectUponInsertion](OutputPortHandle out) { return out->get_typename () == portToConnectUponInsertion->get_typename (); });
319+ if (fromPort != oports.end ())
320+ {
321+ // removeConnection(*portToConnectUponInsertion->firstConnectionId());
319322 requestConnection (fromPort->get (), portToConnectUponInsertion);
323+ }
320324 }
321325 return newMod;
322326 }
323327 }
324328 }
329+ return newMod;
325330}
326331
327332void NetworkEditorController::printNetwork () const
@@ -349,7 +354,7 @@ boost::optional<ConnectionId> NetworkEditorController::requestConnection(const P
349354 PortConnectionDeterminer q;
350355 if (q.canBeConnected (*from, *to))
351356 {
352- ConnectionId id = theNetwork_->connect (ConnectionOutputPort (theNetwork_->lookupModule (desc.out_ .moduleId_ ), desc.out_ .portId_ ),
357+ auto id = theNetwork_->connect (ConnectionOutputPort (theNetwork_->lookupModule (desc.out_ .moduleId_ ), desc.out_ .portId_ ),
353358 ConnectionInputPort (theNetwork_->lookupModule (desc.in_ .moduleId_ ), desc.in_ .portId_ ));
354359 if (!id.id_ .empty ())
355360 connectionAdded_ (desc);
0 commit comments