diff --git a/GUI/Widgets/Fl_Canvas.C b/GUI/Widgets/Fl_Canvas.C index 2fefa37..3cedb0e 100644 --- a/GUI/Widgets/Fl_Canvas.C +++ b/GUI/Widgets/Fl_Canvas.C @@ -582,17 +582,18 @@ istream &operator>>(istream &s, Fl_Canvas &o) s>>NewWire.InputChild; s>>NewWire.InputPort; s>>NewWire.InputTerminal; - - o.m_WireVec.push_back(NewWire); + + // if we can turn on both ports + if (((Fl_DeviceGUI*)(o.child(NewWire.OutputChild)))->AddConnection(NewWire.OutputPort+ + ((Fl_DeviceGUI*)(o.child(NewWire.OutputChild)))->GetInfo()->NumInputs) && + ((Fl_DeviceGUI*)(o.child(NewWire.InputChild)))->AddConnection(NewWire.InputPort)) + { + o.m_WireVec.push_back(NewWire); - // Notify connection by callback - o.cb_Connection(&o,(void*)&NewWire); - o.m_Graph.AddConnection(NewWire.OutputID,NewWire.OutputTerminal,NewWire.InputID,NewWire.InputTerminal); - - // Turn on both ports - ((Fl_DeviceGUI*)(o.child(NewWire.OutputChild)))->AddConnection(NewWire.OutputPort+ - ((Fl_DeviceGUI*)(o.child(NewWire.OutputChild)))->GetInfo()->NumInputs); - ((Fl_DeviceGUI*)(o.child(NewWire.InputChild)))->AddConnection(NewWire.InputPort); + // Notify connection by callback + o.cb_Connection(&o,(void*)&NewWire); + o.m_Graph.AddConnection(NewWire.OutputID,NewWire.OutputTerminal,NewWire.InputID,NewWire.InputTerminal); + } } } @@ -609,16 +610,17 @@ istream &operator>>(istream &s, Fl_Canvas &o) s>>NewWire.InputChild; s>>NewWire.InputPort; - o.m_WireVec.push_back(NewWire); + // if we can turn on both ports + if (((Fl_DeviceGUI*)(o.child(NewWire.OutputChild)))->AddConnection(NewWire.OutputPort+ + ((Fl_DeviceGUI*)(o.child(NewWire.OutputChild)))->GetInfo()->NumInputs) && + ((Fl_DeviceGUI*)(o.child(NewWire.InputChild)))->AddConnection(NewWire.InputPort)) + { + o.m_WireVec.push_back(NewWire); - // Notify connection by callback - o.cb_Connection(&o,(void*)&NewWire); - o.m_Graph.AddConnection(NewWire.OutputID,false,NewWire.InputID,false); - - // Turn on both ports - ((Fl_DeviceGUI*)(o.child(NewWire.OutputChild)))->AddConnection(NewWire.OutputPort+ - ((Fl_DeviceGUI*)(o.child(NewWire.OutputChild)))->GetInfo()->NumInputs); - ((Fl_DeviceGUI*)(o.child(NewWire.InputChild)))->AddConnection(NewWire.InputPort); + // Notify connection by callback + o.cb_Connection(&o,(void*)&NewWire); + o.m_Graph.AddConnection(NewWire.OutputID,false,NewWire.InputID,false); + } } } return s; diff --git a/GUI/Widgets/Fl_DeviceGUI.C b/GUI/Widgets/Fl_DeviceGUI.C index f4cffe3..23ac949 100644 --- a/GUI/Widgets/Fl_DeviceGUI.C +++ b/GUI/Widgets/Fl_DeviceGUI.C @@ -220,11 +220,16 @@ void Fl_DeviceGUI::Setup(const DeviceGUIInfo& Info, bool FirstTime) } } -void Fl_DeviceGUI::AddConnection(int n) +bool Fl_DeviceGUI::AddConnection(int n) { - m_PortVec[n]->Add(); - m_PortVec[n]->value(1); - redraw(); + if ( n < m_PortVec.size() ) + { + m_PortVec[n]->Add(); + m_PortVec[n]->value(1); + redraw(); + return true; + } + return false; } void Fl_DeviceGUI::RemoveConnection(int n) diff --git a/GUI/Widgets/Fl_DeviceGUI.h b/GUI/Widgets/Fl_DeviceGUI.h index 729006e..32bf1ec 100644 --- a/GUI/Widgets/Fl_DeviceGUI.h +++ b/GUI/Widgets/Fl_DeviceGUI.h @@ -95,7 +95,7 @@ public: // aesthitic, to keep track of number of connections to know whether to // draw the port as occupied or not. - void AddConnection(int n); + bool AddConnection(int n); void RemoveConnection(int n); bool GetPortValue(int n) { return m_PortVec[n]->value(); }