fix a segfault caused by re-entrance

at the point when we're connecting a new node to the UI-Bus,
the new node's BusTerm is not yet initialised, since we need
the uplink connection we're about to create for setting up
this BusTerm.

Consequently, the new nodes's ID is not yet initialised,
so we need to pass this endpoint-ID explicitly to the
registration function.
This commit is contained in:
Fischlurch 2015-12-24 22:43:41 +01:00
parent 38e6d635dc
commit 972045d8f8
3 changed files with 8 additions and 6 deletions

View file

@ -87,7 +87,7 @@ namespace ctrl {
BusTerm
BusTerm::attach (ID identity, Tangible& newNode)
{
return BusTerm(identity, theBus_.routeAdd(newNode));
return BusTerm(identity, theBus_.routeAdd (identity,newNode));
}
@ -161,9 +161,9 @@ namespace ctrl {
* @return corresponding up-link for the initiating node to use
*/
BusTerm&
BusTerm::routeAdd (Tangible& node)
BusTerm::routeAdd (ID identity, Tangible& node)
{
return theBus_.routeAdd(node);
return theBus_.routeAdd (identity, node);
}

View file

@ -127,7 +127,7 @@ namespace ctrl{
, theBus_(attached_to)
{ }
virtual BusTerm& routeAdd(Tangible&);
virtual BusTerm& routeAdd(ID,Tangible&);
virtual void routeDetach(ID) noexcept;
};

View file

@ -99,13 +99,15 @@ namespace ctrl{
}
/** add a new down-link connection to the routing table
* @param identity the [endpoint-ID][BusTerm::endpointID_] used
* to address the new element to be connected to the bus.
* @return backlink for the new Tangible's BusTerm to
* attach itself to the Nexus.
*/
virtual BusTerm&
routeAdd (Tangible& newNode) override
routeAdd (ID identity, Tangible& newNode) override
{
routingTable_[newNode] = &newNode;
routingTable_[identity] = &newNode;
return *this;
}