Commit 864131dd authored by Alejandro Homs Puron's avatar Alejandro Homs Puron

* Fixed bug crashing when SyncCtrlObj is deleted before CtAcquisition

parent 1d1d6cb8
......@@ -144,7 +144,6 @@ CtAcquisition::CtAcquisition(HwInterface *hw) :
CtAcquisition::~CtAcquisition()
{
DEB_DESTRUCTOR();
m_hw_sync->unregisterValidRangesCallback(m_valid_ranges_cb);
delete m_valid_ranges_cb;
}
......
......@@ -70,12 +70,14 @@ public:
class ValidRangesCallback
{
DEB_CLASS(DebModHardware,"HwSyncCtrlObj::ValidRangesCallback");
friend class HwSyncCtrlObj;
public:
virtual ~ValidRangesCallback() {};
ValidRangesCallback();
virtual ~ValidRangesCallback();
protected:
virtual void validRangesChanged(const HwSyncCtrlObj::ValidRangesType&) = 0;
private:
friend class HwSyncCtrlObj;
HwSyncCtrlObj* m_hw_sync;
};
HwSyncCtrlObj();
......
......@@ -54,6 +54,7 @@ sipRes = tmpString.c_str();
class ValidRangesCallback
{
public:
ValidRangesCallback();
virtual ~ValidRangesCallback();
protected:
virtual void validRangesChanged(const HwSyncCtrlObj::ValidRangesType&) = 0;
......
......@@ -24,16 +24,29 @@
using namespace lima;
HwSyncCtrlObj::ValidRangesCallback::ValidRangesCallback()
: m_hw_sync(NULL)
{
}
HwSyncCtrlObj::ValidRangesCallback::~ValidRangesCallback()
{
if (m_hw_sync)
m_hw_sync->unregisterValidRangesCallback(this);
}
HwSyncCtrlObj::HwSyncCtrlObj()
: m_acq_mode(Single),
m_valid_ranges_cb(NULL)
{
DEB_CONSTRUCTOR();
DEB_CONSTRUCTOR();
}
HwSyncCtrlObj::~HwSyncCtrlObj()
{
DEB_DESTRUCTOR();
DEB_DESTRUCTOR();
if (m_valid_ranges_cb)
unregisterValidRangesCallback(m_valid_ranges_cb);
}
bool HwSyncCtrlObj::checkAutoExposureMode(AutoExposureMode mode) const
......@@ -92,6 +105,7 @@ void HwSyncCtrlObj::registerValidRangesCallback(ValidRangesCallback *cb)
throw LIMA_CTL_EXC(InvalidValue,"ValidRangesCallback already registered");
}
cb->m_hw_sync = this;
m_valid_ranges_cb = cb;
}
......@@ -107,6 +121,7 @@ void HwSyncCtrlObj::unregisterValidRangesCallback(ValidRangesCallback *cb)
}
m_valid_ranges_cb = NULL;
cb->m_hw_sync = NULL;
}
std::ostream& lima::operator<<(std::ostream& os,const HwSyncCtrlObj::ValidRangesType &range)
......
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