Commit 98eaa235 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX] - fixed a bug in input connectors causing the input to return a valid...

[FIX] - fixed a bug in input connectors causing the input to return a valid pointer even it has been disconnected. This is now fixed.
parent e5110ab7
......@@ -283,6 +283,8 @@ void WModuleConnector::disconnect( boost::shared_ptr<WModuleConnector> con, bool
lock.unlock();
// signal "closed connection"
// NOTE: at this point, there might be an connected input connector even though we disconnected it. This is because of removeFromOwnList.
// The input connectors handle this with an additional member variable denoting their disconnect state
signal_ConnectionClosed( shared_from_this(), con );
con->signal_ConnectionClosed( shared_from_this(), con );
}
......
......@@ -99,8 +99,9 @@ public:
* \param name The name of this connector.
* \param description Short description of this connector.
*/
WModuleInputData( boost::shared_ptr< WModule > module, std::string name = "", std::string description = "" )
:WModuleInputConnector( module, name, description )
WModuleInputData( boost::shared_ptr< WModule > module, std::string name = "", std::string description = "" ):
WModuleInputConnector( module, name, description ),
m_disconnecting( false )
{
};
......@@ -111,6 +112,14 @@ public:
{
};
/**
* Disconnects this connector if connected. If it is not connected: nothing happens.
*
* \param con the connector to disconnect.
* \param removeFromOwnList if true the specified connection is also removed from the own connection list. If false it won't.
*/
virtual void disconnect( boost::shared_ptr<WModuleConnector> con, bool removeFromOwnList = true );
/**
* Gives the currently set data.
*
......@@ -124,7 +133,7 @@ public:
handledUpdate();
// is there something in the list?
if ( m_connected.begin() == m_connected.end() )
if ( m_disconnecting || m_connected.empty() )
{
lock.unlock();
return boost::shared_ptr< T >();
......@@ -170,8 +179,20 @@ public:
protected:
private:
/**
* If true, the returned data will be NULL. Needed because disconnection process is based on multiple steps.
*/
bool m_disconnecting;
};
template < typename T >
void WModuleInputData< T >::disconnect( boost::shared_ptr<WModuleConnector> con, bool removeFromOwnList )
{
m_disconnecting = true;
WModuleInputConnector::disconnect( con, removeFromOwnList );
}
template < typename T >
typename WModuleInputData< T >::PtrType WModuleInputData< T >::create( boost::shared_ptr< WModule > module, std::string name,
std::string description )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment