Skip to content
Snippets Groups Projects
Commit 865c3d19 authored by Mirko Wächter's avatar Mirko Wächter
Browse files

fixed clean up of RobotStateComponent (exception in destructor..)

parent 0a9427c3
No related branches found
No related tags found
No related merge requests found
......@@ -42,11 +42,15 @@ namespace armarx
{
RobotStateComponent::~RobotStateComponent()
{
if (_synchronizedPrx)
try
{
_synchronizedPrx->unref();
if (_synchronizedPrx)
{
_synchronizedPrx->unref();
}
}
ARMARX_VERBOSE << "Destructor";
catch(...)
{}
}
......@@ -119,7 +123,7 @@ namespace armarx
{
SharedRobotInterfacePtr shared = new SharedRobotServant(this->_synchronized);
shared->ref();
this->_synchronizedPrx = SharedRobotInterfacePrx::uncheckedCast(current.adapter->addWithUUID(shared));
this->_synchronizedPrx = SharedRobotInterfacePrx::uncheckedCast(getObjectAdapter()->addWithUUID(shared));
}
return this->_synchronizedPrx;
}
......@@ -128,7 +132,7 @@ namespace armarx
SharedRobotInterfacePrx RobotStateComponent::getRobotSnapshot(const string & time,const Current & current)
{
SharedRobotInterfacePtr p = new SharedRobotServant(this->_synchronized->clone(time));
return SharedRobotInterfacePrx::uncheckedCast(current.adapter->addWithUUID(p));
return SharedRobotInterfacePrx::uncheckedCast(getObjectAdapter()->addWithUUID(p));
}
void RobotStateComponent::reportJointAngles(const NameValueMap& jointAngles, bool aValueChanged, const Current& c)
......
......@@ -75,7 +75,8 @@ void SharedObjectBase::destroy(const Current &c)
#ifdef VERBOSE
ARMARX_ERROR_S << "[SharedObject] destroy " << " " << this << flush;
#endif
} catch (const NotRegisteredException&){
} catch (const NotRegisteredException&e){
// ARMARX_INFO_S << "destroy failed with: " << e.what();
throw ObjectNotExistException(__FILE__, __LINE__);
};
}
......@@ -96,7 +97,7 @@ SharedRobotNodeServant::SharedRobotNodeServant(RobotNodePtr node) :
SharedRobotNodeServant::~SharedRobotNodeServant()
{
#ifdef VERBOSE
ARMARX_LOG_S << "[SharedRobotNodeServant] destruct " << " " << this << flush;
ARMARX_FATAL_S << "[SharedRobotNodeServant] destruct " << " " << this << flush;
#endif
}
......@@ -240,8 +241,14 @@ SharedRobotServant::~SharedRobotServant()
#endif
boost::recursive_mutex::scoped_lock cloneLock(m);
BOOST_FOREACH(NodeCache::value_type value, this->_cachedNodes)
value.second->unref();
for(auto value: this->_cachedNodes)
{
try
{
value.second->unref();
}
catch(...){}
}
}
SharedRobotNodeInterfacePrx SharedRobotServant::getRobotNode(const string &name, const Current &current)
......@@ -249,7 +256,7 @@ SharedRobotNodeInterfacePrx SharedRobotServant::getRobotNode(const string &name,
// ARMARX_LOG_S << "Looking for node: " << name << flush;
assert(_robot);
boost::recursive_mutex::scoped_lock cloneLock(m);
SharedRobotNodeInterfacePrx prx;
if (this->_cachedNodes.find(name) == this->_cachedNodes.end()){
RobotNodePtr robotNode = _robot->getRobotNode(name);
if (!robotNode){
......@@ -260,8 +267,10 @@ SharedRobotNodeInterfacePrx SharedRobotServant::getRobotNode(const string &name,
SharedRobotNodeInterfacePtr servant = new SharedRobotNodeServant(
_robot->getRobotNode(name));
//servant->ref();
this->_cachedNodes[name] = SharedRobotNodeInterfacePrx::uncheckedCast(current.adapter->addWithUUID(servant));
this->_cachedNodes[name]->ref();
prx = SharedRobotNodeInterfacePrx::uncheckedCast(current.adapter->addWithUUID(servant));
prx->ref();
// return prx;
this->_cachedNodes[name] = prx;
}
return this->_cachedNodes[name];
}
......
......@@ -32,7 +32,7 @@ namespace armarx {
public:
virtual void ref(const Ice::Current &c);
virtual void unref(const Ice::Current &c);
virtual void destroy(const Ice::Current &c);
void destroy(const Ice::Current &c);
SharedObjectBase();
private:
unsigned int _referenceCount;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment