]> AND Private Git Repository - blast.git/blobdiff - Dispatcher.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
source connection ok
[blast.git] / Dispatcher.cpp
index bbbb945399fec32d5221e8b6f608b3a2867dd871..10880cc1aa3179367d5413249d97805d5cb0c7bd 100644 (file)
@@ -82,7 +82,7 @@ void Dispatcher::closeCurrentProject() {
 }
 
 bool Dispatcher::createConnectionItem(InterfaceItem *iface1, InterfaceItem *iface2) {
-
+    
   ConnectedInterface* ref1 = iface1->refInter;
   ConnectedInterface* ref2 = iface2->refInter;
   // connect both interface
@@ -90,13 +90,17 @@ bool Dispatcher::createConnectionItem(InterfaceItem *iface1, InterfaceItem *ifac
   bool ok1 = false;
   bool ok2 = false;
 
-  if (ref1->canConnectTo(ref2)) {
-    ok1 = ref1->connectTo(ref2);
-    ok1 = ok1 & ref2->connectFrom(ref1);
-  }
-  if (ref2->canConnectTo(ref1)) {
-    ok2 = ref2->connectTo(ref1);
-    ok2 = ok2 & ref1->connectFrom(ref2);
+  // test the ref1->ref2 connection
+  if ((ref1->canConnectTo(ref2)) && (ref2->canConnectFrom(ref1))) {
+    ref1->connectTo(ref2);
+    ref2->connectFrom(ref1);
+    ok1 = true;
+  }
+  // if the frist one did not work, test ref2->ref1
+  if ((ok1 == false) && (ref2->canConnectTo(ref1)) && (ref1->canConnectFrom(ref2))) {  
+    ref2->connectTo(ref1);
+    ref1->connectFrom(ref2);
+    ok2 = true;
   }
   if ((ok1 == true) || (ok2 == true)) {